本文整理汇总了C++中R1函数的典型用法代码示例。如果您正苦于以下问题:C++ R1函数的具体用法?C++ R1怎么用?C++ R1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R1函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GarbleBlock
void GarbleBlock(unsigned char *block,uint32_t a,uint32_t b,uint32_t c,uint32_t d,uint32_t e)
{
uint32_t W[16];
for(int i=0;i<16;i++) W[i]=(block[4*i+0]<<24)|(block[4*i+1]<<16)|(block[4*i+2]<<8)|block[4*i+3];
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
for(int i=0;i<64;i++) block[i]=W[i/4]>>(i%4)*8;
}
开发者ID:1051215684,项目名称:theunarchiver,代码行数:28,代码来源:RARBug.c
示例2: t03_create_and_free_a_lot_random
void t03_create_and_free_a_lot_random(unsigned int n){
INIT_LOCAL();
onion_dict *dict;
const char *value;
unsigned int i;
dict=onion_dict_new();
FAIL_IF_EQUAL(dict,NULL);
// Linear add
for (i=0;i<n;i++){
char key[16], val[16];
sprintf(key,"key %d",R1(i));
sprintf(val,"val %d",R2(i));
onion_dict_add(dict, key, val, OD_DUP_ALL);
}
// Linear get
for (i=0;i<n;i++){
char key[16], val[16];
sprintf(key,"key %d",R1(i));
sprintf(val,"val %d",R2(i));
value=onion_dict_get(dict, key);
FAIL_IF_NOT_EQUAL_STR(val,value);
}
// remove all
for (i=n;i>0;i--){
char key[16];
int removed;
sprintf(key,"key %d",R1(i-1));
//fprintf(stderr,"%s %d\n",key,i-1);
removed=onion_dict_remove(dict, key);
FAIL_IF_NOT_EQUAL(removed,1);
}
// check removed all
for (i=0;i<n;i++){
char key[16], val[16];
sprintf(key,"key %d",R1(i));
sprintf(val,"val %d",R1(i));
value=onion_dict_get(dict, key);
//fprintf(stderr,"%s %s\n",key,value);
FAIL_IF_NOT_EQUAL(NULL,value);
FAIL_IF_NOT_EQUAL_STR(NULL,value);
}
onion_dict_free(dict);
END_LOCAL();
}
开发者ID:511860050,项目名称:onion,代码行数:54,代码来源:01-hash.c
示例3: vm_run
void vm_run( vm_state_t *vm, opcode_t *opcodes )
{
opcode_t *op = opcodes;
word *regs = vm->regs;
word r1 = 0, r2 = 0, r3 = 0;
static const void * code[256] = {
&&l_NOP, &&l_LOAD, &&l_MOV, &&l_ADD, &&l_SUB, &&l_NOP,
&&l_NOP, &&l_NOP,
NOP128, NOP64, NOP32, NOP16,
&&l_NOP, &&l_NOP, &&l_NOP, &&l_NOP, &&l_NOP, &&l_NOP, &&l_NOP,
&&l_DOWN
};
goto *code[OPCODE(*op)];
l_NOP:
NEXT();
l_LOAD:
r1 = R1(*op);
regs[r1] = *(++op);
NEXT();
l_MOV:
regs[R2(*op)] = regs[R1(*op)];
NEXT();
l_ADD:
regs[R3(*op)] = regs[R1(*op)] + regs[R2(*op)] ;
NEXT();
l_SUB:
regs[R3(*op)] = regs[R1(*op)] - regs[R2(*op)] ;
NEXT();
l_DOWN:
return;
}
int main(int a, char **b)
{
unsigned int i = 0;
vm_state_t vm = { {0} };
opcode_t opcodes[] = {
#include "bytecode"
};
for(i=0;i<500000;i++)
{
vm_run(&vm, opcodes);
}
printf("R3: %08X\n", vm.regs[R3]);
return 0;
}
开发者ID:voidlizard,项目名称:vmcmp,代码行数:51,代码来源:labels.c
示例4: transform
static void transform(uint32_t state[5], uint8_t buffer[64]){
uint32_t block[80];
unsigned int i, a, b, c, d, e;
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
#ifdef CONFIG_SMALL
for(i=0; i<80; i++){
int t;
if(i<16) t= be2me_32(((uint32_t*)buffer)[i]);
else t= rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1);
block[i]= t;
t+= e+rol(a,5);
if(i<40){
if(i<20) t+= ((b&(c^d))^d) +0x5A827999;
else t+= ( b^c ^d) +0x6ED9EBA1;
}else{
if(i<60) t+= (((b|c)&d)|(b&c))+0x8F1BBCDC;
else t+= ( b^c ^d) +0xCA62C1D6;
}
e= d;
d= c;
c= rol(b,30);
b= a;
a= t;
}
#else
for(i=0; i<15; i+=5){
R0(a,b,c,d,e,0+i); R0(e,a,b,c,d,1+i); R0(d,e,a,b,c,2+i); R0(c,d,e,a,b,3+i); R0(b,c,d,e,a,4+i);
}
R0(a,b,c,d,e,15); R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
for(i=20; i<40; i+=5){
R2(a,b,c,d,e,0+i); R2(e,a,b,c,d,1+i); R2(d,e,a,b,c,2+i); R2(c,d,e,a,b,3+i); R2(b,c,d,e,a,4+i);
}
for(; i<60; i+=5){
R3(a,b,c,d,e,0+i); R3(e,a,b,c,d,1+i); R3(d,e,a,b,c,2+i); R3(c,d,e,a,b,3+i); R3(b,c,d,e,a,4+i);
}
for(; i<80; i+=5){
R4(a,b,c,d,e,0+i); R4(e,a,b,c,d,1+i); R4(d,e,a,b,c,2+i); R4(c,d,e,a,b,3+i); R4(b,c,d,e,a,4+i);
}
#endif
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
}
开发者ID:joshdekock,项目名称:jim-ps3ware,代码行数:50,代码来源:sha1.c
示例5: SHA1Transform
void SHA1Transform(uint32 state[5], const unsigned char buffer[SHA1_BLOCK_LENGTH])
{
uint32 a, b, c, d, e;
typedef union {
unsigned char c[64];
uint32 l[16];
} CHAR64LONG16;
CHAR64LONG16 block[1]; /* use array to appear as a pointer */
memcpy(block, buffer, SHA1_BLOCK_LENGTH);
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
#ifdef SHA1HANDSOFF
memset(block, '\0', sizeof(block));
#endif
}
开发者ID:bruceg,项目名称:bglibs,代码行数:50,代码来源:sha1.c
示例6: sOH1
// This calculates the dipole-dipole contribution of a neighboring (source) water molecule to the (target) dipole potential
// Thus, the arguments are the target H through which H-bonding occurs, the pre-calculated target dipole derivative, and the dipole potential container that is being used to track the added contributions
void SFGCalculator::HDipoleDipoleContribution (
const Atom * tH,
const VecR& t_mu,
const VecR& t_com,
const int oh_num,
std::vector<double>& dipolePotential)
{
// Go through one of the target hydrogens and find their H-bonding partners
Atom_ptr_vec hbonds = t.Graph().BondedAtoms(tH, hbond);
for (Atom_it sO = hbonds.begin(); sO != hbonds.end(); sO++) {
// find the source hydrogen, oxygen, center of mass, oh vector, etc.
morita::MoritaH2O * sH2O = static_cast<morita::MoritaH2O *>((*sO)->ParentMolecule());
VecR sOH1 (MDSystem::Distance(*sO, sH2O->GetAtom("H1"))); // in angstroms
VecR sOH2 (MDSystem::Distance(*sO, sH2O->GetAtom("H2")));
VecR sCOM1 ((*sO)->Position() + (sOH1.normalized() * (OH_COM_LENGTH/sfg_units::ANG2BOHR))); // in angstroms
VecR sCOM2 ((*sO)->Position() + (sOH2.normalized() * (OH_COM_LENGTH/sfg_units::ANG2BOHR)));
// now we have to find the center of mass separation vectors, and also the dipole moment derivatives for each of the source OHs
VecR sMu1 (sOH1.normalized() * MU_DERIV_LENGTH); // atomic units
VecR sMu2 (sOH2.normalized() * MU_DERIV_LENGTH);
// The R vectors point from the source to the target
VecR R1 (MDSystem::Distance(sCOM1, t_com)); // angstroms
VecR R2 (MDSystem::Distance(sCOM2, t_com));
// but we are dealing with atomic units, so let's rescale the R vectors to reflect this
R1 *= sfg_units::ANG2BOHR; // converting to atomic units
R2 *= sfg_units::ANG2BOHR;
dipolePotential[oh_num] += this->DipolePotential (t_mu, sMu1, R1);
dipolePotential[oh_num] += this->DipolePotential (t_mu, sMu2, R2);
}
return;
}
开发者ID:eshamay,项目名称:interfacemd,代码行数:36,代码来源:watersfg.cpp
示例7: f5
void f5() {
SomeClass v1, v2(42), v3{42}, v4(42.5);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: SomeClass v1;
// CHECK-FIXES: {{^ }}SomeClass v2(42);
// CHECK-FIXES: {{^ }}SomeClass v3{42};
// CHECK-FIXES: {{^ }}SomeClass v4(42.5);
SomeClass v5 = 42, *p1 = nullptr;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: SomeClass v5 = 42;
// CHECK-FIXES: {{^ }}SomeClass *p1 = nullptr;
Point P1(0., 2.), P2{2., 0.};
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: Point P1(0., 2.);
// CHECK-FIXES: {{^ }}Point P2{2., 0.};
Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
// CHECK-FIXES: {{^ }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
// CHECK-FIXES: {{^ }}Rectangle R3(P1, P2);
// CHECK-FIXES: {{^ }}Rectangle R4{P1, P2};
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:25,代码来源:readability-isolate-declaration.cpp
示例8: push
void YASHE::roundMultiply(NTL::ZZ_pX& output,
const NTL::ZZ_pXMultiplier& a,
const NTL::ZZ_pXMultiplier& b) {
// maximum is q^2 * (maxDegree + 1)
NTL::ZZ_pPush push((cModulus * cModulus)/pModulus);
long n = bigCycloMod.n;
NTL::ZZ_pX product, P1(NTL::INIT_SIZE, n), P2(NTL::INIT_SIZE, n);
NTL::FFTRep R1(NTL::INIT_SIZE, bigCycloMod.l), R2(NTL::INIT_SIZE, bigCycloMod.l);
ToFFTRep(R1, a.val(), bigCycloMod.l);
mul(R2, R1, b.B1);
FromFFTRep(P1, R2, n-1, 2*n-3);
mul(R1, a.B2, b.B2);
ToFFTRep(R2, P1, bigCycloMod.k);
mul(R2, R2, bigCycloMod.FRep);
sub(R1, R1, R2);
FromFFTRep(product, R1, 0, n-1);
output.SetLength(maxDegree + 1);
NTL::ZZ quotient, remainder;
for (long i = 0; i <= maxDegree; i++) {
DivRem(quotient, remainder, pModulus * rep(product[i]), cModulus);
// Rounding using remainder
if (remainder * 2 > cModulus) {
quotient += 1;
}
output[i] = NTL::conv<NTL::ZZ_p>(quotient);
}
}
开发者ID:sportdeath,项目名称:YASHE,代码行数:35,代码来源:yashe.cpp
示例9: UpdateMap
void UpdateMap(vec_zz_p& x, const vec_zz_p& aa,
const zz_pXMultiplier& B, const zz_pXModulus& F)
{
long n = F.n;
vec_zz_p a;
a = aa;
StripZeroes(a);
if (a.length() > n) Error("UpdateMap: bad args");
long i;
if (!B.UseFFT) {
PlainUpdateMap(x, a, B.b, F.f);
StripZeroes(x);
return;
}
fftRep R1(INIT_SIZE, F.k), R2(INIT_SIZE, F.l);
vec_zz_p V1(INIT_SIZE, n);
RevTofftRep(R1, a, F.k, 0, a.length()-1, 0);
mul(R2, R1, F.FRep);
RevFromfftRep(V1, R2, 0, n-2);
for (i = 0; i <= n-2; i++) negate(V1[i], V1[i]);
RevTofftRep(R2, V1, F.l, 0, n-2, n-1);
mul(R2, R2, B.B1);
mul(R1, R1, B.B2);
AddExpand(R2, R1);
RevFromfftRep(x, R2, 0, n-1);
StripZeroes(x);
}
开发者ID:av-elier,项目名称:fast-exponentiation-algs,代码行数:34,代码来源:lzz_pX1.c
示例10: main
int main() {
HWND hwnd = DI8::CreateDefaultWindow(WndProc);
DI8::DirectInput dinput;
auto gameControllers = dinput.gameControllers();
if (gameControllers.empty()) {
std::wcout << L"No game controllers found.\n";
return 0;
}
DI8::GameController ctlr{dinput, gameControllers[0], hwnd};
ctlr.makeBackground();
ctlr.acquire();
DI8::MessageLoop([&]{
Sleep(1000/30);
auto state = ctlr.ps3State();
if (state.L1() && state.R1() && state.start() && state.select()) {
std::wcout << L"See ya!\n";
SendMessage(hwnd, WM_CLOSE, 0, 0);
}
});
}
开发者ID:chrisdevisser,项目名称:Programs,代码行数:26,代码来源:dinput.cpp
示例11: fftOutput
/**
* Precomputation on the evaluation key
* allows for faster key switching
*/
void YASHE::dotEval(NTL::ZZ_pX& output,
const std::vector<NTL::ZZ_pX>& a) {
long n = cycloMod.n;
long da = maxDegree;
NTL::FFTRep fftOutput(NTL::INIT_SIZE, cycloMod.k);
ToFFTRep(fftOutput, NTL::ZZ_pX(0), cycloMod.k);
NTL::ZZ_pX P1(NTL::INIT_SIZE, n), P2(NTL::INIT_SIZE, n);
NTL::FFTRep R1(NTL::INIT_SIZE, cycloMod.l), R2(NTL::INIT_SIZE, cycloMod.l);
for (long i = 0; i < decompSize; i++) {
ToFFTRep(R1, a[i], cycloMod.l);
mul(R2, R1, evalKeyMult[i].B1);
FromFFTRep(P1, R2, n-1, 2*n-3);
reduce(R1, R1, cycloMod.k);
mul(R1, R1, evalKeyMult[i].B2);
ToFFTRep(R2, P1, cycloMod.k);
mul(R2, R2, cycloMod.FRep);
sub(R1, R1, R2);
add(fftOutput, R1, fftOutput);
}
FromFFTRep(output, fftOutput, 0, n-1);
}
开发者ID:sportdeath,项目名称:YASHE,代码行数:31,代码来源:yashe.cpp
示例12: TEST
TEST(TestBookingCalendar, testAvaliableRoomInDayBoundByPrize) {
Hotel hotels;
int count = 4;
for (int i = 0; i < count; i++){
Room R1(i + 1, i + 20, (i+1) * 30, i+400, i+405);
hotels.pushRoomToDatabase(R1);
}
std::vector<Room> * rooms = hotels.getRooms();
EXPECT_EQ(count, rooms->size());
BookingCalendar calendar(2015);
calendar.reserveRoom(rooms->at(2), 2015, 12, 14);
calendar.reserveRoom(rooms->at(3), 2015, 12, 14);
std::vector<Room> result;
calendar.findFreeRoomInDayByPrize(hotels, 70, 2015, 12, 14, result);
EXPECT_EQ(2, result.size());
for (int i = 0; i < 2; i++) {
compareRoom(rooms->at(i), result.at(i));
}
result.clear();
EXPECT_EQ(count, rooms->size());
rooms = NULL;
}
开发者ID:Tomichi,项目名称:semestralka,代码行数:26,代码来源:TestBookingCalendar.cpp
示例13: rubikStep
void rubikStep(char *step)
{
u8 m=0;
for(m=0;step[m]!=0;m++)
{
switch(step[m])
{
case 7:allright90();break;
case 11:F1();break;
case 12:F2();break;
case 13:F3();break;
case 21:B1();break;
case 22:B2();break;
case 23:B3();break;
case 31:R1();break;
case 32:R2();break;
case 33:R3();break;
case 41:L1();break;
case 42:L2();break;
case 43:L3();break;
case 51:U1();break;
case 52:U2();break;
case 53:U3();break;
case 61:D1();break;
case 62:D2();break;
case 63:D3();break;
default:break;
}
}
}
开发者ID:MrChang0,项目名称:rubik,代码行数:30,代码来源:mofang.c
示例14: switch
void FB_RS::executeEvent(int pa_nEIID){
switch(pa_nEIID){
case scm_nEventREQID:
Q1() = !R1() && (S() || Q1());
sendOutputEvent(scm_nEventCNFID);
break;
}
}
开发者ID:EstebanQuerol,项目名称:Black_FORTE,代码行数:8,代码来源:FB_RS.cpp
示例15: SHATransform
/* Hash a single 512-bit block. This is the core of the algorithm. */
static void SHATransform(ULONG State[5], UCHAR Buffer[64])
{
ULONG a, b, c, d, e;
ULONG *Block;
Block = (ULONG*)Buffer;
/* Copy Context->State[] to working variables */
a = State[0];
b = State[1];
c = State[2];
d = State[3];
e = State[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working variables back into Context->State[] */
State[0] += a;
State[1] += b;
State[2] += c;
State[3] += d;
State[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}
开发者ID:Azarien,项目名称:processhacker2,代码行数:47,代码来源:sha.c
示例16: rho
/*
* Pollard's Rho algorithm, as described in the MIT algorithms book.
* Uses Brent's cycle finding
*/
Botan::BigInt rho(const Botan::BigInt& n, Botan::RandomNumberGenerator& rng)
{
auto monty_n = std::make_shared<Botan::Montgomery_Params>(n);
const Botan::Montgomery_Int one(monty_n, monty_n->R1(), false);
Botan::Montgomery_Int x(monty_n, Botan::BigInt::random_integer(rng, 2, n - 3), false);
Botan::Montgomery_Int y = x;
Botan::Montgomery_Int z = one;
Botan::Montgomery_Int t(monty_n);
Botan::BigInt d;
Botan::secure_vector<Botan::word> ws;
size_t i = 1, k = 2;
while(true)
{
i++;
if(i >= 0xFFFF0000) // bad seed? too slow? bail out
{
break;
}
x.square_this(ws); // x = x^2
x.add(one, ws);
t = y;
t.sub(x, ws);
z.mul_by(t, ws);
if(i == k || i % 128 == 0)
{
d = Botan::gcd(z.value(), n);
z = one;
if(d == n)
{
// TODO Should rewind here
break;
}
if(d != 1)
return d;
}
if(i == k)
{
y = x;
k = 2 * k;
}
}
// failed
return 0;
}
开发者ID:evpo,项目名称:EncryptPad,代码行数:62,代码来源:math.cpp
示例17: Transform
static void Transform(Sha* sha)
{
word32 W[SHA_BLOCK_SIZE / sizeof(word32)];
/* Copy context->state[] to working vars */
word32 a = sha->digest[0];
word32 b = sha->digest[1];
word32 c = sha->digest[2];
word32 d = sha->digest[3];
word32 e = sha->digest[4];
/* nearly 1 K bigger in code size but 25% faster */
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
/* Add the working vars back into digest state[] */
sha->digest[0] += a;
sha->digest[1] += b;
sha->digest[2] += c;
sha->digest[3] += d;
sha->digest[4] += e;
}
开发者ID:cconlon,项目名称:cyassl-android-ndk,代码行数:45,代码来源:sha.c
示例18: R1
// data constructor:
void LagrangianScleronomousRTest::testBuildLagrangianScleronomousR2()
{
SP::LagrangianScleronomousR R1(new LagrangianScleronomousR("TestPlugin:hSclero", "TestPlugin:G0Sclero"));
CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildLagrangianScleronomousR3a : ", R1->getType() == RELATION::Lagrangian, true);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildLagrangianScleronomousR3b : ", R1->getSubType() == RELATION::ScleronomousR, true);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildLagrangianScleronomousR3c : ", R1->gethName() == "TestPlugin:hSclero", true);
CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildLagrangianScleronomousR3d : ", R1->getJachqName() == "TestPlugin:G0Sclero", true);
std::cout << " data Constructor LagrangianScleronomousR ok" <<std::endl;
}
开发者ID:bremond,项目名称:siconos,代码行数:10,代码来源:LagrangianScleronomousRTest.cpp
示例19: oh1_unit
void SFGCalculator::DipoleDipoleContribution (morita::MoritaH2O& water, std::vector<double>& dipolePotential) {
/*********************************************************************************************
* Calculation of the frequency shift due to dipole-dipole interaction with neighboring waters
*********************************************************************************************/
//int coord = static_cast<int>(graph->WaterCoordination(&water));
//int N = graph->NumHBonds(&water);
//if (N > 3) {
// two OH bonds on the target water, so we will have two sets of shifts from dipole-dipole interactions
// the dipole moment derivatives for each OH bond are calculated along the O->H vector, and have a magnitude of the same vector as in the MH paper.
// For the dipole moment derivative, we can just take the one from the molecular frame and rotate it out to the lab frame
// Originally the dipole moment derivative was assumed to be along the OH bond... as per DSW below:
VecR oh1_unit (water.OH1()->normalized());
VecR oh2_unit (water.OH2()->normalized());
VecR mu1 (oh1_unit * MU_DERIV_LENGTH); // these are in atomic units
VecR mu2 (oh2_unit * MU_DERIV_LENGTH);
// But perhaps another idea, if taking the actual dipole deriv. doesn't work, is to take the dot product of the actual one with the OH bond unit vector. (?)
// find the center of mass locations for both target OH bonds
VecR com1 (water.O()->Position() + (oh1_unit * OH_COM_LENGTH/sfg_units::ANG2BOHR)); // this is in Angstroms...
VecR com2 (water.O()->Position() + (oh2_unit * OH_COM_LENGTH/sfg_units::ANG2BOHR));
// Now we go through the calculation of each neighboring H-bonded water (the "source" waters, acting as the "source" of the dipole-dipole interactions) and find the contribution from each OH dipole. First we'll start with source OH's that are bound through the target oxygen. (I'll use the nomenclature of sH to mean source-hydrogen, and tO to mean target oxygen, etc.)
Atom_ptr_vec hbonds = t.Graph().BondedAtoms(water.O(), hbond); // all the H's H-bonding to the target O
for (Atom_it sH = hbonds.begin(); sH != hbonds.end(); sH++) {
// find the source hydrogen, oxygen, center of mass, oh vector, etc.
morita::MoritaH2O * sH2O = static_cast<morita::MoritaH2O *>((*sH)->ParentMolecule());
Atom * sO = sH2O->GetAtom("O");
VecR sOH (MDSystem::Distance (sO, *sH));
//VecR sOH (sO->Position().MinVector (sH->Position(), MDSystem::Dimensions())); // source OH vector
VecR sCOM (sO->Position() + (sOH.normalized() * (OH_COM_LENGTH/sfg_units::ANG2BOHR))); // source OH center of mass in angstroms
// now we have to find the center of mass separation vectors, and also the dipole moment derivatives for each of the source OHs
VecR sMu (sOH.normalized() * MU_DERIV_LENGTH); // in atomic units
// The R vectors point from the source to the target
VecR R1 (MDSystem::Distance(sCOM,com1));
VecR R2 (MDSystem::Distance(sCOM,com2));
// but we are dealing with atomic units, so let's rescale the R vectors to reflect this
R1 *= sfg_units::ANG2BOHR;
R2 *= sfg_units::ANG2BOHR;
dipolePotential[0] += this->DipolePotential (mu1, sMu, R1); // the result is in atomic units
dipolePotential[1] += this->DipolePotential (mu2, sMu, R2);
}
HDipoleDipoleContribution (water.H1(), mu1, com1, 0, dipolePotential);
HDipoleDipoleContribution (water.H2(), mu2, com2, 1, dipolePotential);
//}
return;
}
开发者ID:eshamay,项目名称:interfacemd,代码行数:57,代码来源:watersfg.cpp
示例20: unary_plus_test
void unary_plus_test()
{
quan::resistance::MR R1(4.7);
quan::resistance::MR R2 = +R1;
QUAN_CHECK_EQUAL(R1.numeric_value(),R2.numeric_value());
quan::magnetic_permeability_<int>::mH_per_m mp1(987.51);
quan::magnetic_permeability::mH_per_m mp2 = + mp1;
QUAN_CHECK(mp1.numeric_value() == mp2.numeric_value());
QUAN_CHECK(mp1.numeric_value() == 988);
}
开发者ID:duststorm,项目名称:quan-trunk,代码行数:10,代码来源:unary_plus.cpp
注:本文中的R1函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论