本文整理汇总了C++中identity函数的典型用法代码示例。如果您正苦于以下问题:C++ identity函数的具体用法?C++ identity怎么用?C++ identity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了identity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VideoConsumer
/**
* @brief
*
* @param provider
*/
QueuedVideoFilter::QueuedVideoFilter( AudioVideoProvider &provider ) :
VideoConsumer( cClass(), provider, FeedLink( FEED_QUEUED, AudioVideoProvider::videoFramesOnly ) ),
VideoProvider( cClass(), provider.name() ),
Thread( identity() )
{
}
示例2: identity
eMatrix3x3::eMatrix3x3()
{
identity();
}
示例3: errno_assert
int zmq::xrep_t::xrecv (msg_t *msg_, int flags_)
{
// if there is a prefetched identity, return it.
if (prefetched == 2)
{
int rc = msg_->init_size (prefetched_id.size ());
errno_assert (rc == 0);
memcpy (msg_->data (), prefetched_id.data (), prefetched_id.size ());
msg_->set_flags (msg_t::more);
prefetched = 1;
return 0;
}
// If there is a prefetched message, return it.
if (prefetched == 1) {
int rc = msg_->move (prefetched_msg);
errno_assert (rc == 0);
more_in = msg_->flags () & msg_t::more ? true : false;
prefetched = 0;
return 0;
}
pipe_t *pipe = NULL;
while (true) {
// Get next message part.
int rc = fq.recvpipe (msg_, flags_, &pipe);
if (rc != 0)
return -1;
// If identity is received, change the key assigned to the pipe.
if (likely (!(msg_->flags () & msg_t::identity)))
break;
zmq_assert (!more_in);
// Empty identity means we can preserve the auto-generated identity.
if (msg_->size () != 0) {
// Actual change of the identity.
outpipes_t::iterator it = outpipes.begin ();
while (it != outpipes.end ()) {
if (it->second.pipe == pipe) {
blob_t identity ((unsigned char*) msg_->data (),
msg_->size ());
pipe->set_identity (identity);
outpipes.erase (it);
outpipe_t outpipe = {pipe, true};
outpipes.insert (outpipes_t::value_type (identity,
outpipe));
break;
}
++it;
}
zmq_assert (it != outpipes.end ());
}
}
// If we are in the middle of reading a message, just return the next part.
if (more_in) {
more_in = msg_->flags () & msg_t::more ? true : false;
return 0;
}
// We are at the beginning of a new message. Move the message part we
// have to the prefetched and return the ID of the peer instead.
int rc = prefetched_msg.move (*msg_);
errno_assert (rc == 0);
prefetched = 1;
rc = msg_->close ();
errno_assert (rc == 0);
blob_t identity = pipe->get_identity ();
rc = msg_->init_size (identity.size ());
errno_assert (rc == 0);
memcpy (msg_->data (), identity.data (), identity.size ());
msg_->set_flags (msg_t::more);
return 0;
}
示例4: gfx_step
int gfx_step( uint32_t *fifo, uint32_t jmp, int off )
{
static bool init_particles = false;
if( !init_particles )
{
init_particles = true;
for( size_t i = 0; i < INUMBER; ++i )
{
dt[i] = ( rand() & 63 ) + 32;
rnds[i][0] = 360.0f * i / (float)( INUMBER );//rnd( 0.0f, 360.0f );
rnds[i][1] = rnd( -0.2f, +0.2f );
rnds[i][2] = rnd( -0.8f, +0.3f );
rnds[i][3] = rnd( 0.3f, 1.0f );
insts[i].time = rand();
insts[i].col[0] = rnd( 0.8f, 1.0f );
insts[i].col[1] = rnd( 0.8f, 1.0f );
insts[i].col[2] = rnd( 0.8f, 1.0f );
insts[i].col[3] = 1.0f;
}
}
for( size_t i = 0; i < INUMBER; ++i )
{
insts[i].time += dt[i];
identity( insts[i].mat );
rotatef( 80.0f, 1.0f, 0.0f, 0.0f, insts[i].mat );
rotatef( off * 0.5f + rnds[i][0], 0.0f, 0.0f, 1.0f, insts[i].mat );
translatef( 1.6f, rnds[i][1], rnds[i][2], insts[i].mat );
scalef( rnds[i][3], insts[i].mat );
float d = insts[i].mat[11];
d = ( 1.0f - 0.6f * d );
insts[i].scale = rnds[i][3];
insts[i].col[0] = d;
insts[i].col[1] = 0.5f + d;
insts[i].col[2] = d;
//translatef( 1.0f * sin( t * rnds[i][0] ), 1.0f * cos( t * rnds[i][0] ), 1.0f * sin( t * rnds[i][2] ), insts[i].mat );
}
clear_buffer_t clear;
clear.clearR = clear.clearG = clear.clearB = clear.clearA = clear.clearD = 1;
clear.rgba = 50 + ( 10 << 8 ) + ( 5 << 16 );
clear.depth = 0xffff;
static job_t job;
static size_t curr = 0x0;
job.pd.insts = (uint32_t)insts;
job.pd.isize = INUMBER;
job.pd.dynamic = (uint32_t)( dynamic ) + curr * 24;
job.pd.fx = (uint32_t)fx.get_data();
job.pd.atlas = (uint32_t)atlas.get_data();
job.pd.asize = atlas.get_size();
job.kick_job( );
job.join();
uint32_t *ptr = fifo;
static float angle = 180.0f;
ptr += setup_surfaces_with_offset( ptr, off % 3 );
ptr += clear_buffers( &clear, ptr, Nv3D );
ptr += set_mvp( ptr, angle );
ptr += set_cnst( ptr );
//ptr += troll_texture.set( ptr );
//ptr += troll.set( ptr );
//ptr += custom.set( ptr );
ptr += particles.set( ptr );
ptr += particle_texture.set( ptr );
ptr += draw_primitives( 0, QUADS, curr, job.pd.quads * 4, ptr, Nv3D );
curr += job.pd.quads * 4;// + 128;
curr = ( curr + 16 ) & 2047;
//printf( "%d \n", job.pd.quads );
ptr += jump_to_address( ptr, jmp );
return ptr - fifo;
}
示例5: translation
void translation(double tx, double ty, LTransform m)
{
identity(m);
m[2][0] = tx;
m[2][1] = ty;
}
示例6: invert
GLboolean
invert(GLdouble src[16], GLdouble inverse[16])
{
double t;
int i, j, k, swap;
GLdouble tmp[4][4];
identity(inverse);
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
tmp[i][j] = src[i*4+j];
}
}
for (i = 0; i < 4; i++) {
/* look for largest element in column. */
swap = i;
for (j = i + 1; j < 4; j++) {
if (fabs(tmp[j][i]) > fabs(tmp[i][i])) {
swap = j;
}
}
if (swap != i) {
/* swap rows. */
for (k = 0; k < 4; k++) {
t = tmp[i][k];
tmp[i][k] = tmp[swap][k];
tmp[swap][k] = t;
t = inverse[i*4+k];
inverse[i*4+k] = inverse[swap*4+k];
inverse[swap*4+k] = t;
}
}
if (tmp[i][i] == 0) {
/* no non-zero pivot. the matrix is singular, which
shouldn't happen. This means the user gave us a bad
matrix. */
return GL_FALSE;
}
t = tmp[i][i];
for (k = 0; k < 4; k++) {
tmp[i][k] /= t;
inverse[i*4+k] /= t;
}
for (j = 0; j < 4; j++) {
if (j != i) {
t = tmp[j][i];
for (k = 0; k < 4; k++) {
tmp[j][k] -= tmp[i][k]*t;
inverse[j*4+k] -= inverse[i*4+k]*t;
}
}
}
}
return GL_TRUE;
}
示例8: GetDiagonal
void GetDiagonal( const Matrix<T>& A, Matrix<T>& d, Int offset )
{
DEBUG_ONLY(CSE cse("GetDiagonal"))
function<T(T)> identity( []( T alpha ) { return alpha; } );
GetMappedDiagonal( A, d, identity, offset );
}
示例9: identity
///////////////////////////////////////////////////////////////////////////
// inline functions for Mat2
///////////////////////////////////////////////////////////////////////////
inline Mat2::Mat2()
{
// initially identity matrix
identity();
}
示例10: identity
etk::Matrix2::Matrix2() {
// TODO: Remove this ...
identity();
}
示例11: metric
virtual double metric(stk::mesh::Entity& element, bool& valid)
{
valid = true;
JacobianUtil jacA, jacW;
int spatialDim = m_eMesh->get_spatial_dim();
double A_ = 0.0, W_ = 0.0; // current and reference detJ
jacA(A_, *m_eMesh, element, m_coord_field_current, m_topology_data);
jacW(W_, *m_eMesh, element, m_coord_field_original, m_topology_data);
double val=0.0, val_shape=0.0;
MsqMatrix<3,3> Ident;
identity(Ident);
MsqMatrix<3,3> WI, T;
for (int i=0; i < jacA.m_num_nodes; i++)
{
double detAi = jacA.m_detJ[i];
if (detAi < 0)
{
valid = false;
}
MsqMatrix<3,3>& W = jacW.m_J[i];
MsqMatrix<3,3>& A = jacA.m_J[i];
// frob2 = h^2 + h^2 + 1
// frob21 = 2 h^2
// f = h sqrt(2)
// det = h*h
// met = f*f / (det*2) - 1
// frob3 = 3 h^2
// f = h sqrt(3)
// det = h*h*h
// met = f*f*f/(3^3/2 *det) - 1 = f*f*f/(3*sqrt(3)*det) - 1
double shape_metric = 0.0;
if (std::fabs(detAi) > 1.e-15)
{
inverse(W, WI);
product(A, WI, T);
double d = det(T);
double f = my_sqr_Frobenius(T);
if (spatialDim==2)
{
// all our jacobians are 3D, with a 1 in the 3,3 slot for 2d, so we subtract it here
f = f - 1.0;
f = std::sqrt(f);
double fac = 2.0;
double den = fac * d;
shape_metric = (f*f)/den - 1.0;
}
else
{
f = std::sqrt(f);
double fac = 3.0*std::sqrt(3.0);
double den = fac * d;
shape_metric = (f*f*f)/den - 1.0;
}
//shape_metric = std::fabs(shape_metric);
//shape_metric = f/std::pow(den,1./3.) - 1.0;
}
val_shape += shape_metric;
//val_shape += std::fabs(shape_metric);
//val_shape += shape_metric*shape_metric;
}
val = val_shape;
//val = val_shape*val_shape;
return val;
}
示例12: Verificator
Verificator()
{
Name identity(IDENTITY_NAME);
Name keyName = m_keyChain.getDefaultKeyNameForIdentity(identity);
m_publicKey = m_keyChain.getPublicKey(keyName);
};
示例13: zmq_assert
int zmq::xrep_t::xsend (zmq_msg_t *msg_, int flags_)
{
// If this is the first part of the message it's the identity of the
// peer to send the message to.
if (!more_out) {
zmq_assert (!current_out);
// If we have malformed message (prefix with no subsequent message)
// then just silently ignore it.
if (msg_->flags & ZMQ_MSG_MORE) {
more_out = true;
// Find the pipe associated with the identity stored in the prefix.
// If there's no such pipe just silently ignore the message.
blob_t identity ((unsigned char*) zmq_msg_data (msg_),
zmq_msg_size (msg_));
outpipes_t::iterator it = outpipes.find (identity);
if (it != outpipes.end ()) {
current_out = it->second.writer;
zmq_msg_t empty;
int rc = zmq_msg_init (&empty);
zmq_assert (rc == 0);
if (!current_out->check_write (&empty)) {
it->second.active = false;
more_out = false;
current_out = NULL;
}
rc = zmq_msg_close (&empty);
zmq_assert (rc == 0);
}
}
int rc = zmq_msg_close (msg_);
zmq_assert (rc == 0);
rc = zmq_msg_init (msg_);
zmq_assert (rc == 0);
return 0;
}
// Check whether this is the last part of the message.
more_out = msg_->flags & ZMQ_MSG_MORE;
// Push the message into the pipe. If there's no out pipe, just drop it.
if (current_out) {
bool ok = current_out->write (msg_);
zmq_assert (ok);
if (!more_out) {
current_out->flush ();
current_out = NULL;
}
}
else {
int rc = zmq_msg_close (msg_);
zmq_assert (rc == 0);
}
// Detach the message from the data buffer.
int rc = zmq_msg_init (msg_);
zmq_assert (rc == 0);
return 0;
}
示例14: identity
bool PlayPG::doLogin() {
const auto logger = el::Loggers::getLogger("PlayPG");
if (!socket.isConnected()) {
socket.connect();
if (socket.hasError()) {
return false;
}
if (!socket.waitForActivity(2000)) {
logger->error("Server didn't respond in time.");
return false;
}
int read = socket.recv();
const auto opcode = socket.getShort();
logger->info("Got %v bytes, opcode %v.", read, opcode);
if (opcode != static_cast<opcode_type_t>(ServerOpcode::LOGIN_AUTHENTICATION_CHALLENGE)) {
logger->info("Got opcode %v which doesn't match the expected value. Ignoring.");
socket.clear();
return false;
}
const uint16_t jsonSize = socket.getShort();
auto json = socket.getStringByLength(jsonSize);
// logger->info("JSON: %v", json);
APG::JSONSerializer<AuthenticationChallenge> challengeS11N;
const auto challenge = challengeS11N.fromJSON(json.c_str());
logger->info("Got challenge from \"%v\", v%v (%v).", challenge.name, challenge.version, challenge.versionHash);
// logger->info("Got pubkey: %v", challenge.pubKey);
serverPubKey = challenge.pubKey;
crypto = std::make_unique<RSACrypto>(serverPubKey, true);
socket.clear();
if (std::strcmp(challenge.version.c_str(), Version::versionString) != 0
|| std::strcmp(challenge.versionHash.c_str(), Version::gitHash) != 0) {
logger->info("Version check failed.");
VersionMismatch mismatchPacket;
socket.put(&mismatchPacket.buffer);
socket.send();
return false;
}
logger->info("Version check successful.");
} else {
socket.clear();
}
const auto encPass = crypto->encryptStringPublic("testa");
logger->info("Sending %v byte password", encPass.size());
AuthenticationIdentity identity(username, encPass);
socket.put(&identity.buffer);
const auto sentAuthDetailBytes = socket.send();
logger->info("Sent %v auth detail bytes, opcode %v.", sentAuthDetailBytes, (opcode_type_t) identity.opcode);
socket.clear();
socket.waitForActivity(2000);
socket.recv();
const auto respOpcode = socket.getShort();
if (respOpcode != static_cast<opcode_type_t>(ServerOpcode::LOGIN_AUTHENTICATION_RESPONSE)) {
return false;
}
const auto respSize = socket.getShort();
const auto respJSON = socket.getStringByLength(respSize);
logger->info("Got authentication response: %v", respJSON);
APG::JSONSerializer<AuthenticationResponse> responseS11N;
const auto response = responseS11N.fromJSON(respJSON.c_str());
if (!response.successful) {
logger->info("Authentication failed with username %v: %v", username, response.message);
if (response.attemptsRemaining == 0) {
socket.disconnect();
}
return false;
}
return true;
//.........这里部分代码省略.........
示例15: regionNames_
// Construct with length.
Foam::searchableSurfaces::searchableSurfaces(const label size)
:
PtrList<searchableSurface>(size),
regionNames_(size),
allSurfaces_(identity(size))
{}