本文整理汇总了C++中V函数的典型用法代码示例。如果您正苦于以下问题:C++ V函数的具体用法?C++ V怎么用?C++ V使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了V函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FSAL_proxy_setclientid_force
/**
* FSAL_proxy_setclientid_force:
* Client ID negociation
*
* \param p_context (input):
* Authentication context for the operation (user,...).
*
* \return Major error codes :
* - ERR_FSAL_NO_ERROR (no error)
* - ERR_FSAL_FAULT (a NULL pointer was passed as mandatory argument)
* - Other error codes can be returned :
* ERR_FSAL_ACCESS, ERR_FSAL_IO, ...
*/
fsal_status_t FSAL_proxy_setclientid_force(proxyfsal_op_context_t * p_context)
{
int rc;
fsal_status_t fsal_status;
COMPOUND4args argnfs4;
COMPOUND4res resnfs4;
#define FSAL_CLIENTID_NB_OP_ALLOC 1
nfs_argop4 argoparray[FSAL_CLIENTID_NB_OP_ALLOC];
nfs_resop4 resoparray[FSAL_CLIENTID_NB_OP_ALLOC];
nfs_client_id4 nfsclientid;
cb_client4 cbproxy;
char clientid_name[MAXNAMLEN];
char cbaddr[MAXNAMLEN];
char cbnetid[MAXNAMLEN];
clientid4 resultclientid;
struct timeval timeout = TIMEOUTRPC;
LogEvent( COMPONENT_FSAL, "Negociating a new ClientId with the remote server" ) ;
/* sanity checks.
*/
if(!p_context)
Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_InitClientContext);
/* Client id negociation is to be done only one time for the whole FSAL */
P(fsal_clientid_mutex_renew);
/* Setup results structures */
argnfs4.argarray.argarray_val = argoparray;
resnfs4.resarray.resarray_val = resoparray;
argnfs4.minorversion = 0;
argnfs4.tag.utf8string_val = NULL;
argnfs4.tag.utf8string_len = 0;
argnfs4.argarray.argarray_len = 0;
snprintf(clientid_name, MAXNAMLEN, "GANESHA NFSv4 Proxy Pid=%u", getpid());
nfsclientid.id.id_len = strlen(clientid_name);
nfsclientid.id.id_val = clientid_name;
snprintf(nfsclientid.verifier, NFS4_VERIFIER_SIZE, "%x", (int)ServerBootTime);
cbproxy.cb_program = 0;
strncpy(cbnetid, "tcp", MAXNAMLEN);
strncpy(cbaddr, "127.0.0.1", MAXNAMLEN);
#ifdef _USE_NFS4_1
cbproxy.cb_location.na_r_netid = cbnetid;
cbproxy.cb_location.na_r_addr = cbaddr;
#else
cbproxy.cb_location.r_netid = cbnetid;
cbproxy.cb_location.r_addr = cbaddr;
#endif
COMPOUNDV4_ARG_ADD_OP_SETCLIENTID(argnfs4, nfsclientid, cbproxy);
TakeTokenFSCall();
p_context->user_credential.user = 0;
p_context->user_credential.group = 0;
p_context->user_credential.nbgroups = 0;
/* Call the NFSv4 function */
rc = COMPOUNDV4_EXECUTE_SIMPLE(p_context, argnfs4, resnfs4);
if(rc != RPC_SUCCESS)
{
ReleaseTokenFSCall();
V(fsal_clientid_mutex_renew);
Return(ERR_FSAL_IO, rc, INDEX_FSAL_unlink);
}
ReleaseTokenFSCall();
if(resnfs4.status != NFS4_OK)
{
V(fsal_clientid_mutex_renew);
return fsal_internal_proxy_error_convert(resnfs4.status,
INDEX_FSAL_InitClientContext);
}
resultclientid =
resnfs4.resarray.resarray_val[0].nfs_resop4_u.opsetclientid.SETCLIENTID4res_u.
resok4.clientid;
/* Step 2: Confirm the client id */
argnfs4.minorversion = 0;
//.........这里部分代码省略.........
示例2: Cart
vector Cart(float r, float t)
{
return V(r*cos(t),r*sin(t));
}
示例3: decomposition
/* Subroutine */ int dggsvd_(char *jobu, char *jobv, char *jobq, integer *m,
integer *n, integer *p, integer *k, integer *l, doublereal *a,
integer *lda, doublereal *b, integer *ldb, doublereal *alpha,
doublereal *beta, doublereal *u, integer *ldu, doublereal *v, integer
*ldv, doublereal *q, integer *ldq, doublereal *work, integer *iwork,
integer *info)
{
/* -- LAPACK driver routine (version 2.0) --
Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
Courant Institute, Argonne National Lab, and Rice University
September 30, 1994
Purpose
=======
DGGSVD computes the generalized singular value decomposition (GSVD)
of an M-by-N real matrix A and P-by-N real matrix B:
U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R )
where U, V and Q are orthogonal matrices, and Z' is the transpose
of Z. Let K+L = the effective numerical rank of the matrix (A',B')',
then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and
D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the
following structures, respectively:
If M-K-L >= 0,
K L
D1 = K ( I 0 )
L ( 0 C )
M-K-L ( 0 0 )
K L
D2 = L ( 0 S )
P-L ( 0 0 )
N-K-L K L
( 0 R ) = K ( 0 R11 R12 )
L ( 0 0 R22 )
where
C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
S = diag( BETA(K+1), ... , BETA(K+L) ),
C**2 + S**2 = I.
R is stored in A(1:K+L,N-K-L+1:N) on exit.
If M-K-L < 0,
K M-K K+L-M
D1 = K ( I 0 0 )
M-K ( 0 C 0 )
K M-K K+L-M
D2 = M-K ( 0 S 0 )
K+L-M ( 0 0 I )
P-L ( 0 0 0 )
N-K-L K M-K K+L-M
( 0 R ) = K ( 0 R11 R12 R13 )
M-K ( 0 0 R22 R23 )
K+L-M ( 0 0 0 R33 )
where
C = diag( ALPHA(K+1), ... , ALPHA(M) ),
S = diag( BETA(K+1), ... , BETA(M) ),
C**2 + S**2 = I.
(R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored
( 0 R22 R23 )
in B(M-K+1:L,N+M-K-L+1:N) on exit.
The routine computes C, S, R, and optionally the orthogonal
transformation matrices U, V and Q.
In particular, if B is an N-by-N nonsingular matrix, then the GSVD of
A and B implicitly gives the SVD of A*inv(B):
A*inv(B) = U*(D1*inv(D2))*V'.
If ( A',B')' has orthonormal columns, then the GSVD of A and B is
also equal to the CS decomposition of A and B. Furthermore, the GSVD
can be used to derive the solution of the eigenvalue problem:
A'*A x = lambda* B'*B x.
In some literature, the GSVD of A and B is presented in the form
U'*A*X = ( 0 D1 ), V'*B*X = ( 0 D2 )
where U and V are orthogonal and X is nonsingular, D1 and D2 are
``diagonal''. The former GSVD form can be converted to the latter
form by taking the nonsingular matrix X as
X = Q*( I 0 )
( 0 inv(R) ).
Arguments
=========
//.........这里部分代码省略.........
示例4: test_uloc
void
test_uloc(void)
{
ZNotice_t z1, z2, z0, z4;
String *s1, *s2, *s0, *s4;
struct sockaddr_in who1, who2, who3, who0, who4;
int ret;
puts("uloc storage routines");
TEST(ulogin_find_user("nonexistent") == -1);
/* fake up just enough */
who1.sin_family = AF_INET;
who1.sin_port = 1;
who1.sin_addr.s_addr = INADDR_LOOPBACK;
z1.z_class_inst = "user1";
z1.z_port = 1;
z1.z_message = "here\0now\0this\0";
z1.z_message_len = 14;
s1 = make_string(z1.z_class_inst, 0);
TEST(ulogin_add_user(&z1, NET_ANN, &who1) == 0);
TEST(ulogin_find_user("user1") != -1);
who2.sin_family = AF_INET;
who2.sin_port = 2;
who2.sin_addr.s_addr = INADDR_LOOPBACK;
z2.z_class_inst = "user2";
z2.z_port = 2;
z2.z_message = "here\0now\0this\0";
z2.z_message_len = 14;
s2 = make_string(z2.z_class_inst, 0);
TEST(ulogin_add_user(&z2, NET_ANN, &who2) == 0);
TEST(ulogin_find_user("user2") != -1);
TEST(locations[ulogin_find_user("user1")].user == s1);
TEST(locations[ulogin_find_user("user2")].user == s2);
TEST(ulogin_add_user(&z1, NET_ANN, &who1) == 0);
TEST(locations[ulogin_find_user("user1")].user == s1);
TEST(locations[ulogin_find_user("user2")].user == s2);
who3.sin_family = AF_INET;
who3.sin_port = 3;
who3.sin_addr.s_addr = INADDR_LOOPBACK;
TEST(ulogin_find("user1", &who3.sin_addr, 3) == -1);
who0.sin_family = AF_INET;
who0.sin_port = 3;
who0.sin_addr.s_addr = INADDR_LOOPBACK;
z0.z_class_inst = "user0";
z0.z_port = 3;
z0.z_message = "here\0now\0this\0";
z0.z_message_len = 14;
s0 = make_string(z0.z_class_inst, 0);
TEST(ulogin_add_user(&z0, NET_ANN, &who0) == 0);
TEST(ulogin_find_user("user0") != -1);
TEST(locations[ulogin_find_user("user1")].user == s1);
TEST(locations[ulogin_find_user("user2")].user == s2);
TEST(ulogin_remove_user(&z0, &who0, &ret) == NET_ANN && ret == 0);
/* 1 = NOLOC */
TEST(ulogin_remove_user(&z0, &who0, &ret) == NONE && ret == 1);
TEST(ulogin_add_user(&z0, NET_ANN, &who0) == 0);
TEST(ulogin_remove_user(&z1, &who0, &ret) == NET_ANN && ret == 0);
V(ulogin_flush_user(&z0));
TEST(ulogin_find_user("user0") == -1);
TEST(ulogin_add_user(&z0, NET_ANN, &who0) == 0);
TEST(ulogin_add_user(&z1, NET_ANN, &who1) == 0);
V(ulogin_flush_user(&z1));
TEST(ulogin_find_user("user1") == -1);
who4.sin_family = AF_INET;
who4.sin_port = 4;
who4.sin_addr.s_addr = INADDR_ANY;
z4.z_class_inst = "user4";
z4.z_port = 4;
z4.z_message = "here\0now\0this\0";
z4.z_message_len = 14;
s4 = make_string(z4.z_class_inst, 0);
TEST(ulogin_add_user(&z4, NET_ANN, &who4) == 0);
V(uloc_flush_client(&who2));
TEST(locations[ulogin_find_user("user0")].user == s0);
TEST(ulogin_find_user("user1") == -1);
TEST(ulogin_find_user("user2") == -1);
//.........这里部分代码省略.........
示例5: SIDE
/* Subroutine */ int zggbak_(char *job, char *side, integer *n, integer *ilo,
integer *ihi, doublereal *lscale, doublereal *rscale, integer *m,
doublecomplex *v, integer *ldv, integer *info)
{
/* -- LAPACK routine (version 2.0) --
Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
Courant Institute, Argonne National Lab, and Rice University
September 30, 1994
Purpose
=======
ZGGBAK forms the right or left eigenvectors of a complex generalized
eigenvalue problem A*x = lambda*B*x, by backward transformation on
the computed eigenvectors of the balanced pair of matrices output by
ZGGBAL.
Arguments
=========
JOB (input) CHARACTER*1
Specifies the type of backward transformation required:
= 'N': do nothing, return immediately;
= 'P': do backward transformation for permutation only;
= 'S': do backward transformation for scaling only;
= 'B': do backward transformations for both permutation and
scaling.
JOB must be the same as the argument JOB supplied to ZGGBAL.
SIDE (input) CHARACTER*1
= 'R': V contains right eigenvectors;
= 'L': V contains left eigenvectors.
N (input) INTEGER
The number of rows of the matrix V. N >= 0.
ILO (input) INTEGER
IHI (input) INTEGER
The integers ILO and IHI determined by ZGGBAL.
1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
LSCALE (input) DOUBLE PRECISION array, dimension (N)
Details of the permutations and/or scaling factors applied
to the left side of A and B, as returned by ZGGBAL.
RSCALE (input) DOUBLE PRECISION array, dimension (N)
Details of the permutations and/or scaling factors applied
to the right side of A and B, as returned by ZGGBAL.
M (input) INTEGER
The number of columns of the matrix V. M >= 0.
V (input/output) COMPLEX*16 array, dimension (LDV,M)
On entry, the matrix of right or left eigenvectors to be
transformed, as returned by ZTGEVC.
On exit, V is overwritten by the transformed eigenvectors.
LDV (input) INTEGER
The leading dimension of the matrix V. LDV >= max(1,N).
INFO (output) INTEGER
= 0: successful exit.
< 0: if INFO = -i, the i-th argument had an illegal value.
Further Details
===============
See R.C. Ward, Balancing the generalized eigenvalue problem,
SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.
=====================================================================
Test the input parameters
Parameter adjustments
Function Body */
/* System generated locals */
integer v_dim1, v_offset, i__1;
/* Local variables */
static integer i, k;
extern logical lsame_(char *, char *);
static logical leftv;
extern /* Subroutine */ int zswap_(integer *, doublecomplex *, integer *,
doublecomplex *, integer *), xerbla_(char *, integer *),
zdscal_(integer *, doublereal *, doublecomplex *, integer *);
static logical rightv;
#define LSCALE(I) lscale[(I)-1]
#define RSCALE(I) rscale[(I)-1]
#define V(I,J) v[(I)-1 + ((J)-1)* ( *ldv)]
//.........这里部分代码省略.........
示例6: parse_preproc_data
int UbermasterProcess::main_loop()
{
boost::timer::auto_cpu_timer t;
program_options.splash_screen();
//parse the options
program_options.startup(); // tests for existence of necessary files, etc.
//if desired, display the options
if (program_options.verbose_level()>=3)
program_options.display_current_options();
parse_preproc_data("preproc_data", &solve_options.PPD);
int num_vars = get_num_vars_PPD(solve_options.PPD);
NumericalIrreducibleDecomposition witness_data;
witness_data.populate(&solve_options.T);
WitnessSet W = witness_data.choose(program_options);
if (W.num_points()==0) {
std::cout << "no witness points, cannot decompose anything..." << std::endl;
return 1;
}
W.get_variable_names(num_vars);
W.set_input_filename(program_options.input_filename());
if (program_options.verbose_level()>=1) {
W.print_to_screen();
}
VertexSet V(num_vars);
V.set_tracker_config(&solve_options.T);
V.set_same_point_tolerance(1e1*solve_options.T.real_threshold);
vec_mp *pi = (vec_mp *) br_malloc(W.dimension()*sizeof(vec_mp ));
for (int ii=0; ii<W.dimension(); ii++) {
init_vec_mp2(pi[ii],W.num_variables(), solve_options.T.AMP_max_prec);
pi[ii]->size = W.num_variables();
}
get_projection(pi, program_options, W.num_variables(), W.dimension());
for (int ii=0; ii<W.dimension(); ii++) {
V.add_projection(pi[ii]);
}
if (program_options.primary_mode()==BERTINIREAL) {
bertini_real(W,pi,V);
}
else if(program_options.primary_mode()==CRIT)
{
critreal(W,pi,V);
}
for (int ii=0; ii<W.dimension(); ii++)
clear_vec_mp(pi[ii]);
free(pi);
// dismiss the workers
int sendme = TERMINATE;
MPI_Bcast(&sendme, 1, MPI_INT, 0, MPI_COMM_WORLD);
return SUCCESSFUL;
}
示例7: VAR
{ NULL, NULL, 0, 0},
};
/*XXXX these next two are duplicates or near-duplicates from config.c */
#define VAR(name,conftype,member,initvalue) \
{ name, CONFIG_TYPE_ ## conftype, STRUCT_OFFSET(or_state_t, member), \
initvalue }
/** As VAR, but the option name and member name are the same. */
#define V(member,conftype,initvalue) \
VAR(#member, conftype, member, initvalue)
/** Array of "state" variables saved to the ~/.tor/state file. */
static config_var_t state_vars_[] = {
/* Remember to document these in state-contents.txt ! */
V(AccountingBytesReadInInterval, MEMUNIT, NULL),
V(AccountingBytesWrittenInInterval, MEMUNIT, NULL),
V(AccountingExpectedUsage, MEMUNIT, NULL),
V(AccountingIntervalStart, ISOTIME, NULL),
V(AccountingSecondsActive, INTERVAL, NULL),
V(AccountingSecondsToReachSoftLimit,INTERVAL, NULL),
V(AccountingSoftLimitHitAt, ISOTIME, NULL),
V(AccountingBytesAtSoftLimit, MEMUNIT, NULL),
VAR("EntryGuard", LINELIST_S, EntryGuards, NULL),
VAR("EntryGuardDownSince", LINELIST_S, EntryGuards, NULL),
VAR("EntryGuardUnlistedSince", LINELIST_S, EntryGuards, NULL),
VAR("EntryGuardAddedBy", LINELIST_S, EntryGuards, NULL),
VAR("EntryGuardPathBias", LINELIST_S, EntryGuards, NULL),
VAR("EntryGuardPathUseBias", LINELIST_S, EntryGuards, NULL),
V(EntryGuards, LINELIST_V, NULL),
示例8: read_in_map
void read_in_map ( const cv::FileNode& node, V &result )
{
if(DEBUG_YML_IO)
cout << "reading a value" << endl;
read(node,result,V());
}
示例9: main
int main(int argc, char *argv[])
{
//定义共享缓冲区及其信号灯
int readbuf_id = shmget(IPC_PRIVATE, CACHE_LENGTH + sizeof(unsigned),
IPC_CREAT | IPC_EXCL | 0666);
int rbuf_empty = semget(IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | 0666);
int rbuf_max = semget(IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | 0666);
int writebuf_id = shmget(IPC_PRIVATE, CACHE_LENGTH + sizeof(unsigned),
IPC_CREAT | IPC_EXCL | 0666);
int wbuf_empty = semget(IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | 0666);
int wbuf_max = semget(IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | 0666);
int finish_id = semget(IPC_PRIVATE, 1, IPC_CREAT | IPC_EXCL | 0666);
int get_id = 0;
int put_id = 0;
int copy_id = 0;
union semun semopts;
FILE *out;
FILE *in;
int n;
//打开源和目标文件
if (argc != 3)
{
puts("arguments error");
return 0;
}
if ((in = fopen(argv[1], "rb")) == NULL)
{
puts("can't open input file");
return 0;
}
if ((out = fopen(argv[2], "wb")) == NULL)
{
puts("can't open output file");
fclose(in);
return 0;
}
//信号灯赋值
semopts.val = 1;
semctl(rbuf_empty, 0, SETVAL, semopts);
semctl(wbuf_empty, 0, SETVAL, semopts);
semopts.val = 0;
semctl(rbuf_max, 0, SETVAL, semopts);
semctl(wbuf_max, 0, SETVAL, semopts);
semctl(finish_id, 0, SETVAL, semopts);
/*semctl(part_over, 0, SETVAL, semopts);*/
/*semctl(over, 0, SETVAL, semopts);*/
// get
if ((get_id = fork()) == 0)
{
unsigned char *s = shmat(readbuf_id, 0, 0);
puts("get:start to get");
do
{
P(rbuf_empty, 0);
//加入copy
n = fread(s + sizeof(unsigned), 1, CACHE_LENGTH, in);
/*n = fread(s + sizeof(unsigned), 1, 2, in);*/
printf("read: %d\n", n);
/*putchar('\n');*/
*(unsigned *)s = n;
/*fwrite(s + sizeof(unsigned), 1, *(unsigned *)s, stdout);*/
V(rbuf_max, 0);
if (*(unsigned *)s == 0)
break;
} while (1);
fclose(in);
/*sleep(5);*/
P(finish_id, 0);
shmdt(s);
//请加入保证三个进程同步结束的机制
puts("get: get ended");
return 0;
}
// copy
if ((copy_id = fork()) == 0)
{
unsigned char *s1 = shmat(readbuf_id, 0, 0);
unsigned char *s2 = shmat(writebuf_id, 0, 0);
char buf[CACHE_LENGTH + sizeof(unsigned)];
puts("copy: start to copy");
do
{
P(rbuf_max, 0);
//加入内容
n = *(unsigned *)s1;
printf("copy: %d\n", n);
memcpy(buf, s1, CACHE_LENGTH + sizeof(unsigned));
//.........这里部分代码省略.........
示例10: CORE_zgblrx
int
CORE_zgblrx(int uplo, int N,
PLASMA_desc *A,
PLASMA_Complex64_t *V,
PLASMA_Complex64_t *TAU,
int st,
int ed,
int eltsize)
{
int NB, J1, J2;
int len1, len2, t1ed, t2st;
int i;
PLASMA_desc vA=*A;
/* Check input arguments */
if (N < 0) {
coreblas_error(2, "Illegal value of N");
return -2;
}
if (ed <= st) {
coreblas_error(6, "Illegal value of st and ed (internal)");
return -6;
}
/* Quick return */
if (N == 0)
return PLASMA_SUCCESS;
NB = A->mb;
if( uplo == PlasmaLower ){
/* ========================
* LOWER CASE
* ========================*/
for (i = ed; i >= st+1 ; i--){
/* apply reflector from the left (horizontal row) and from the right for only the diagonal 2x2.*/
J1 = st;
J2 = i-2;
t1ed = (J2/NB)*NB;
t2st = max(t1ed+1,J1);
len1 = t1ed-J1+1;
len2 = J2-t2st+1;
if(len1>0)CORE_zlarfx2(PlasmaLeft, len1 , *V(i), conj(*TAU(i)), A(i-1, J1 ), ELTLDD(vA, (i-1)), A(i, J1 ), ELTLDD(vA, i) );
if(len2>0)CORE_zlarfx2(PlasmaLeft, len2 , *V(i), conj(*TAU(i)), A(i-1, t2st), ELTLDD(vA, (i-1)), A(i, t2st), ELTLDD(vA, i) );
CORE_zlarfx2ce(PlasmaLower, V(i), TAU(i), A(i-1,i-1), A(i,i-1), A(i,i));
}
/* APPLY RIGHT ON THE REMAINING ELEMENT OF KERNEL 1 */
for (i = ed; i >= st+1 ; i--){
J1 = i+1;
J2 = min(ed,N);
t1ed = (J2/NB)*NB;
t2st = max(t1ed+1,J1);
len1 = t1ed-J1+1;
len2 = J2-t2st+1;
if(len1>0)CORE_zlarfx2(PlasmaRight, len1, conj(*V(i)), conj(*TAU(i)), A(J1,i-1), ELTLDD(vA, J1) , A(J1 , i), ELTLDD(vA, J1) );
if(len2>0)CORE_zlarfx2(PlasmaRight, len2, conj(*V(i)), conj(*TAU(i)), A(t2st,i-1), ELTLDD(vA, t2st), A(t2st, i), ELTLDD(vA, t2st) );
}
} else {
/* ========================
* UPPER CASE
* ========================*/
for (i = ed; i >= st+1 ; i--){
/* apply reflector from the left (horizontal row) and from the right for only the diagonal 2x2.*/
J1 = st;
J2 = i-2;
t1ed = (J2/NB)*NB;
t2st = max(t1ed+1,J1);
len1 = t1ed-J1+1;
len2 = J2-t2st+1;
if(len1>0)CORE_zlarfx2(PlasmaRight, len1, conj(*V(i)), conj(*TAU(i)), A(J1,i-1), ELTLDD(vA, J1) , A(J1 , i), ELTLDD(vA, J1) );
if(len2>0)CORE_zlarfx2(PlasmaRight, len2, conj(*V(i)), conj(*TAU(i)), A(t2st,i-1), ELTLDD(vA, t2st), A(t2st, i), ELTLDD(vA, t2st) );
CORE_zlarfx2ce(PlasmaUpper, V(i), TAU(i), A(i-1,i-1), A(i-1, i), A(i,i));
}
/* APPLY LEFT ON THE REMAINING ELEMENT OF KERNEL 1 */
for (i = ed; i >= st+1 ; i--){
J1 = i+1;
J2 = min(ed,N);
t1ed = (J2/NB)*NB;
t2st = max(t1ed+1,J1);
len1 = t1ed-J1+1;
len2 = J2-t2st+1;
if(len1>0)CORE_zlarfx2(PlasmaLeft, len1 , *V(i), conj(*TAU(i)), A(i-1, J1 ), ELTLDD(vA, (i-1)), A(i, J1 ), ELTLDD(vA, i) );
if(len2>0)CORE_zlarfx2(PlasmaLeft, len2 , *V(i), conj(*TAU(i)), A(i-1, t2st), ELTLDD(vA, (i-1)), A(i, t2st), ELTLDD(vA, i) );
}
} /* end of else for the upper case */
return PLASMA_SUCCESS;
}
示例11: V
void D3D9statemanager::setSamplerStateBlock( DWORD stage, Texture::ClampMode clampmode, Texture::FilterMode filtermode )
{
int hash = stage << 24 | clampmode << 16 | filtermode;
HRESULT hr;
Dict<int,IDirect3DStateBlock9*>::const_iterator it = m_states.find(hash);
if (it != m_states.end()) {
if (m_stageSamplerStates[stage] != it->second) {
V(it->second->Apply());
m_stageSamplerStates[stage] = it->second;
}
return;
}
IDirect3DStateBlock9* state = 0;
d3d9Device->BeginStateBlock();
switch (clampmode) {
case Texture::CM_Clamp:
case Texture::CM_ClampToEdge:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSW, D3DTADDRESS_CLAMP);
break;
case Texture::CM_ClampToBorder:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSW, D3DTADDRESS_BORDER);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_BORDERCOLOR, 0);
break;
case Texture::CM_Repeat:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_ADDRESSW, D3DTADDRESS_WRAP);
}
switch (filtermode) {
case Texture::FM_Nearest:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_POINT);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
break;
case Texture::FM_Linear:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
break;
case Texture::FM_Bilinear:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
break;
case Texture::FM_Trilinear:
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
d3d9StateManager->SetSamplerState(stage, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
break;
}
d3d9Device->EndStateBlock(&state);
m_states[hash] = state;
state->Apply();
m_stageSamplerStates[stage] = state;
}
示例12: point1Start
// From http://www.gamedev.net/community/forums/topic.asp?topic_id=467789 -
// intersection of cylinder with ray
void Foam::searchableCylinder::findLineAll
(
const point& start,
const point& end,
pointIndexHit& near,
pointIndexHit& far
) const
{
near.setMiss();
far.setMiss();
vector point1Start(start-point1_);
vector point2Start(start-point2_);
vector point1End(end-point1_);
// Quick rejection of complete vector outside endcaps
scalar s1 = point1Start&unitDir_;
scalar s2 = point1End&unitDir_;
if ((s1 < 0 && s2 < 0) || (s1 > magDir_ && s2 > magDir_))
{
return;
}
// Line as P = start+t*V where V is unit vector and t=[0..mag(end-start)]
vector V(end-start);
scalar magV = mag(V);
if (magV < ROOTVSMALL)
{
return;
}
V /= magV;
// We now get the nearest intersections to start. This can either be
// the intersection with the end plane or with the cylinder side.
// Get the two points (expressed in t) on the end planes. This is to
// clip any cylinder intersection against.
scalar tPoint1;
scalar tPoint2;
// Maintain the two intersections with the endcaps
scalar tNear = VGREAT;
scalar tFar = VGREAT;
{
scalar s = (V&unitDir_);
if (mag(s) > VSMALL)
{
tPoint1 = -s1/s;
tPoint2 = -(point2Start&unitDir_)/s;
if (tPoint2 < tPoint1)
{
Swap(tPoint1, tPoint2);
}
if (tPoint1 > magV || tPoint2 < 0)
{
return;
}
// See if the points on the endcaps are actually inside the cylinder
if (tPoint1 >= 0 && tPoint1 <= magV)
{
if (radius2(start+tPoint1*V) <= sqr(radius_))
{
tNear = tPoint1;
}
}
if (tPoint2 >= 0 && tPoint2 <= magV)
{
if (radius2(start+tPoint2*V) <= sqr(radius_))
{
// Check if already have a near hit from point1
if (tNear <= 1)
{
tFar = tPoint2;
}
else
{
tNear = tPoint2;
}
}
}
}
else
{
// Vector perpendicular to cylinder. Check for outside already done
// above so just set tpoint to allow all.
tPoint1 = -VGREAT;
tPoint2 = VGREAT;
}
}
const vector x = point1Start ^ unitDir_;
const vector y = V ^ unitDir_;
const scalar d = sqr(radius_);
//.........这里部分代码省略.........
示例13: dnp3_p_init_counter
void dnp3_p_init_counter(void)
{
H_RULE (bit, h_bits(1,false));
H_RULE (ignore, h_ignore(bit));
H_RULE (reserved, dnp3_p_reserved(1));
H_ARULE(flags, h_sequence(bit, // ONLINE
bit, // RESTART
bit, // COMM_LOST
bit, // REMOTE_FORCED
bit, // LOCAL_FORCED
ignore, // (ROLLOVER - obsolete)
bit, // DISCONTINUITY
reserved,
NULL));
H_RULE (val32, h_uint32());
H_RULE (val16, h_uint16());
H_ARULE(ctr32, val32);
H_ARULE(ctr16, val16);
H_ARULE(ctr32_flag, h_sequence(flags, val32, NULL));
H_ARULE(ctr16_flag, h_sequence(flags, val16, NULL));
H_ARULE(ctr32_flag_t, h_sequence(flags, val32, dnp3_p_dnp3time, NULL));
H_ARULE(ctr16_flag_t, h_sequence(flags, val16, dnp3_p_dnp3time, NULL));
// group 20: counters...
H_RULE(oblock_32bit_flag, dnp3_p_oblock(G_V(CTR, 32BIT), ctr32_flag));
H_RULE(oblock_16bit_flag, dnp3_p_oblock(G_V(CTR, 16BIT), ctr16_flag));
H_RULE(oblock_32bit_noflag, dnp3_p_oblock(G_V(CTR, 32BIT_NOFLAG), ctr32));
H_RULE(oblock_16bit_noflag, dnp3_p_oblock(G_V(CTR, 16BIT_NOFLAG), ctr16));
dnp3_p_ctr_rblock = dnp3_p_rblock(G(CTR), V(CTR, 32BIT),
V(CTR, 16BIT),
V(CTR, 32BIT_NOFLAG),
V(CTR, 32BIT_NOFLAG), 0);
dnp3_p_ctr_fblock = dnp3_p_specific_rblock(G(CTR), DNP3_VARIATION_ANY);
dnp3_p_ctr_oblock = h_choice(oblock_32bit_flag,
oblock_16bit_flag,
oblock_32bit_noflag,
oblock_16bit_noflag,
NULL);
// group 21: frozen counters...
H_RULE(oblock_frz32bit_flag, dnp3_p_oblock(G_V(FROZENCTR, 32BIT), ctr32_flag));
H_RULE(oblock_frz16bit_flag, dnp3_p_oblock(G_V(FROZENCTR, 16BIT), ctr16_flag));
H_RULE(oblock_frz32bit_flag_t, dnp3_p_oblock(G_V(FROZENCTR, 32BIT_TIME), ctr32_flag_t));
H_RULE(oblock_frz16bit_flag_t, dnp3_p_oblock(G_V(FROZENCTR, 16BIT_TIME), ctr16_flag_t));
H_RULE(oblock_frz32bit_noflag, dnp3_p_oblock(G_V(FROZENCTR, 32BIT_NOFLAG), ctr32));
H_RULE(oblock_frz16bit_noflag, dnp3_p_oblock(G_V(FROZENCTR, 16BIT_NOFLAG), ctr16));
dnp3_p_frozenctr_rblock = dnp3_p_rblock(G(FROZENCTR),
V(FROZENCTR, 32BIT),
V(FROZENCTR, 16BIT),
V(FROZENCTR, 32BIT_TIME),
V(FROZENCTR, 16BIT_TIME),
V(FROZENCTR, 32BIT_NOFLAG),
V(FROZENCTR, 32BIT_NOFLAG), 0);
dnp3_p_frozenctr_oblock = h_choice(oblock_frz32bit_flag,
oblock_frz16bit_flag,
oblock_frz32bit_flag_t,
oblock_frz16bit_flag_t,
oblock_frz32bit_noflag,
oblock_frz16bit_noflag,
NULL);
// group 22: counter events...
H_RULE(oblock_ev32bit_flag, dnp3_p_oblock(G_V(CTREV, 32BIT), ctr32_flag));
H_RULE(oblock_ev16bit_flag, dnp3_p_oblock(G_V(CTREV, 16BIT), ctr16_flag));
H_RULE(oblock_ev32bit_flag_t, dnp3_p_oblock(G_V(CTREV, 32BIT_TIME), ctr32_flag_t));
H_RULE(oblock_ev16bit_flag_t, dnp3_p_oblock(G_V(CTREV, 16BIT_TIME), ctr16_flag_t));
dnp3_p_ctrev_rblock = dnp3_p_rblock(G(CTREV), V(CTREV, 32BIT),
V(CTREV, 16BIT),
V(CTREV, 32BIT_TIME),
V(CTREV, 16BIT_TIME), 0);
dnp3_p_ctrev_oblock = h_choice(oblock_ev32bit_flag,
oblock_ev16bit_flag,
oblock_ev32bit_flag_t,
oblock_ev16bit_flag_t,
NULL);
// group 21: frozen counter events...
H_RULE(oblock_frzev32bit_flag, dnp3_p_oblock(G_V(FROZENCTREV, 32BIT), ctr32_flag));
H_RULE(oblock_frzev16bit_flag, dnp3_p_oblock(G_V(FROZENCTREV, 16BIT), ctr16_flag));
H_RULE(oblock_frzev32bit_flag_t, dnp3_p_oblock(G_V(FROZENCTREV, 32BIT_TIME), ctr32_flag_t));
H_RULE(oblock_frzev16bit_flag_t, dnp3_p_oblock(G_V(FROZENCTREV, 16BIT_TIME), ctr16_flag_t));
dnp3_p_frozenctrev_rblock = dnp3_p_rblock(G(FROZENCTREV),
V(FROZENCTREV, 32BIT),
V(FROZENCTREV, 16BIT),
V(FROZENCTREV, 32BIT_TIME),
V(FROZENCTREV, 16BIT_TIME), 0);
dnp3_p_frozenctrev_oblock = h_choice(oblock_frzev32bit_flag,
oblock_frzev16bit_flag,
oblock_frzev32bit_flag_t,
oblock_frzev16bit_flag_t,
NULL);
}
示例14: getProperty
//----------------------------------------------------------------------------------------------
/// Examine the chi squared as a function of fitting parameters and estimate
/// errors for each parameter.
void CalculateChiSquared::estimateErrors() {
// Number of fiting parameters
auto nParams = m_function->nParams();
// Create an output table for displaying slices of the chi squared and
// the probabilitydensity function
auto pdfTable = API::WorkspaceFactory::Instance().createTable();
std::string baseName = getProperty("Output");
if (baseName.empty()) {
baseName = "CalculateChiSquared";
}
declareProperty(make_unique<API::WorkspaceProperty<API::ITableWorkspace>>(
"PDFs", "", Kernel::Direction::Output),
"The name of the TableWorkspace in which to store the "
"pdfs of fit parameters");
setPropertyValue("PDFs", baseName + "_pdf");
setProperty("PDFs", pdfTable);
// Create an output table for displaying the parameter errors.
auto errorsTable = API::WorkspaceFactory::Instance().createTable();
auto nameColumn = errorsTable->addColumn("str", "Parameter");
auto valueColumn = errorsTable->addColumn("double", "Value");
auto minValueColumn = errorsTable->addColumn("double", "Value at Min");
auto leftErrColumn = errorsTable->addColumn("double", "Left Error");
auto rightErrColumn = errorsTable->addColumn("double", "Right Error");
auto quadraticErrColumn = errorsTable->addColumn("double", "Quadratic Error");
auto chiMinColumn = errorsTable->addColumn("double", "Chi2 Min");
errorsTable->setRowCount(nParams);
declareProperty(make_unique<API::WorkspaceProperty<API::ITableWorkspace>>(
"Errors", "", Kernel::Direction::Output),
"The name of the TableWorkspace in which to store the "
"values and errors of fit parameters");
setPropertyValue("Errors", baseName + "_errors");
setProperty("Errors", errorsTable);
// Calculate initial values
double chiSquared = 0.0;
double chiSquaredWeighted = 0.0;
double dof = 0;
API::FunctionDomain_sptr domain;
API::FunctionValues_sptr values;
m_domainCreator->createDomain(domain, values);
calcChiSquared(*m_function, nParams, *domain, *values, chiSquared,
chiSquaredWeighted, dof);
// Value of chi squared for current parameters in m_function
double chi0 = chiSquared;
// Fit data variance
double sigma2 = chiSquared / dof;
bool useWeighted = getProperty("Weighted");
if (useWeighted) {
chi0 = chiSquaredWeighted;
sigma2 = 0.0;
}
if (g_log.is(Kernel::Logger::Priority::PRIO_DEBUG)) {
g_log.debug() << "chi0=" << chi0 << '\n';
g_log.debug() << "sigma2=" << sigma2 << '\n';
g_log.debug() << "dof=" << dof << '\n';
}
// Parameter bounds that define a volume in the parameter
// space within which the chi squared is being examined.
GSLVector lBounds(nParams);
GSLVector rBounds(nParams);
// Number of points in lines for plotting
size_t n = 100;
pdfTable->setRowCount(n);
const double fac = 1e-4;
// Loop over each parameter
for (size_t ip = 0; ip < nParams; ++ip) {
// Add columns for the parameter to the pdf table.
auto parName = m_function->parameterName(ip);
nameColumn->read(ip, parName);
// Parameter values
auto col1 = pdfTable->addColumn("double", parName);
col1->setPlotType(1);
// Chi squared values
auto col2 = pdfTable->addColumn("double", parName + "_chi2");
col2->setPlotType(2);
// PDF values
auto col3 = pdfTable->addColumn("double", parName + "_pdf");
col3->setPlotType(2);
double par0 = m_function->getParameter(ip);
double shift = fabs(par0 * fac);
if (shift == 0.0) {
shift = fac;
}
// Make a slice along this parameter
GSLVector dir(nParams);
dir.zero();
dir[ip] = 1.0;
//.........这里部分代码省略.........
示例15: V
/* The following #define specifies the packing of the four components
* into the compact INT32 representation.
* Note that this formula must match the actual arithmetic encoder
* and decoder implementation. The implementation has to be changed
* if this formula is changed.
* The current organization is leaned on Markus Kuhn's JBIG
* implementation (jbig_tab.c).
*/
#define V(i,a,b,c,d) (((INT32)a << 16) | ((INT32)c << 8) | ((INT32)d << 7) | b)
const INT32 jpeg_aritab[113+1] = {
/*
* Index, Qe_Value, Next_Index_LPS, Next_Index_MPS, Switch_MPS
*/
V( 0, 0x5a1d, 1, 1, 1 ),
V( 1, 0x2586, 14, 2, 0 ),
V( 2, 0x1114, 16, 3, 0 ),
V( 3, 0x080b, 18, 4, 0 ),
V( 4, 0x03d8, 20, 5, 0 ),
V( 5, 0x01da, 23, 6, 0 ),
V( 6, 0x00e5, 25, 7, 0 ),
V( 7, 0x006f, 28, 8, 0 ),
V( 8, 0x0036, 30, 9, 0 ),
V( 9, 0x001a, 33, 10, 0 ),
V( 10, 0x000d, 35, 11, 0 ),
V( 11, 0x0006, 9, 12, 0 ),
V( 12, 0x0003, 10, 13, 0 ),
V( 13, 0x0001, 12, 13, 0 ),
V( 14, 0x5a7f, 15, 15, 1 ),
V( 15, 0x3f25, 36, 16, 0 ),