本文整理汇总了C++中S1函数的典型用法代码示例。如果您正苦于以下问题:C++ S1函数的具体用法?C++ S1怎么用?C++ S1使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了S1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sc_main
int sc_main(int ac, char *av[])
{
sc_signal<double> in1;
sc_signal<double> in2;
sc_signal<double> sum;
sc_signal<double> diff;
sc_signal<double> prod;
sc_signal<double> quot;
sc_signal<double> powr;
powr = 0.0;
sc_clock clk("CLOCK", 20.0, SC_NS, 0.5, 0.0, SC_NS);
numgen N("STIMULUS", clk, in1, in2);
stage1 S1("Stage1", clk, in1, in2, sum, diff);
stage2 S2("Stage2", clk, sum, diff, prod, quot);
stage3 S3("Stage3", clk, prod, quot, powr);
display D("Display", clk, powr);
sc_start(1000, SC_NS);
return 0;
}
示例2: Rprintf
void CParam::iterate(int iter, CData &Data, CFeasibilityMap &FM, CHyperParam &hyper, Uniform &randUnif, int n_simul) {
if (hyper.f_Sigma < 0) { //if we use default hyper parameters
hyper.f_Sigma = Data.n_var-Data.n_balance_edit+1;
}
if (K == -1) {
Rprintf( "The number of components has not been set\n");
return;
}
if (K < 0) { //the K has been changed and delayed re-initilization is needed
//cout << "Initilizing parameters" << endl;
initizalize(Data,-K,FM,randUnif,n_simul);
}
//clock_t start = clock(), diff;
// S1. // vector_r
S1(iter, randUnif, Data, FM, n_simul);
/*
diff = clock() - start;
int msec = diff * 1000 / CLOCKS_PER_SEC;
<< "s1:" << msec << endl;
start = clock();
*/
// S2-add. // Y_in | S_i for sum(s_i) >= 2
S2_add(randUnif,Data);
S3_Z_in(Data);
S4_Z_out(Data);
S5_MuSigma(Data, hyper.f_Sigma,hyper.h_Mu);
S6_pi();
S7_alpha(hyper.a_alpha, hyper.b_alpha);
S8_Phi(hyper.f_Sigma, hyper.a_Phi, hyper.b_Phi);
}
示例3: TEST
TEST(InputTest, CppUnitLite)
{
std::stringstream Out, Out1, Out2;
std::string Line, Message;
// Default sample file where everything is expected to be OK.
Sudoku S("Sample.txt", Out, false);
while(std::getline(Out, Line))
{
if (Line.find("Count") != std::string::npos)
Message = Line;
}
CHECK_EQUAL(Message, "Count = 14890");
// Sample file with incomplete lines or delimeters between characters.
Sudoku S1("SampleBad1.txt", Out1, true);
S1.IOFile(Out1);
while(std::getline(Out1, Line))
{
if (Line.find("Line") != std::string::npos)
Message = Line;
}
CHECK_EQUAL(Message, "Line 8 incomplete or mal-formatted.");
// Sample file with excess data or otherwise no valid solution.
Sudoku S2("SampleBad2.txt", Out2, true);
S2.IOFile(Out2);
Out2.str("");
S2.IOStats(Out2);
CHECK_EQUAL(Out2.str(), "\nNo solution found.\n\n");
}
示例4: pi_deleglise_rivat1
/// Calculate the number of primes below x using the
/// Deleglise-Rivat algorithm.
/// Run time: O(x^(2/3) / (log x)^2) operations, O(x^(1/3) * (log x)^3) space.
///
int64_t pi_deleglise_rivat1(int64_t x)
{
if (x < 2)
return 0;
double alpha = get_alpha_deleglise_rivat(x);
int64_t x13 = iroot<3>(x);
int64_t y = (int64_t) (x13 * alpha);
int64_t z = x / y;
int64_t c = PhiTiny::get_c(y);
int64_t p2 = P2(x, y, 1);
vector<int32_t> mu = generate_moebius(y);
vector<int32_t> lpf = generate_least_prime_factors(y);
int64_t pi_y = pi_legendre(y, 1);
int64_t s1 = S1(x, y, c, 1);
int64_t s2 = S2(x, y, z, c, lpf, mu);
int64_t phi = s1 + s2;
int64_t sum = phi + pi_y - 1 - p2;
return sum;
}
示例5: pi_lmo3
/// Calculate the number of primes below x using the
/// Lagarias-Miller-Odlyzko algorithm.
/// Run time: O(x^(2/3)) operations, O(x^(1/3) * (log x)^2) space.
///
int64_t pi_lmo3(int64_t x)
{
if (x < 2)
return 0;
double alpha = get_alpha_lmo(x);
int64_t x13 = iroot<3>(x);
int64_t y = (int64_t) (x13 * alpha);
int64_t c = PhiTiny::get_c(y);
int64_t p2 = P2(x, y, 1);
vector<int32_t> mu = generate_moebius(y);
vector<int32_t> lpf = generate_least_prime_factors(y);
vector<int32_t> primes = generate_primes(y);
int64_t pi_y = primes.size() - 1;
int64_t s1 = S1(x, y, c, 1);
int64_t s2 = S2(x, y, c, primes, lpf, mu);
int64_t phi = s1 + s2;
int64_t sum = phi + pi_y - 1 - p2;
return sum;
}
示例6: _BRSHA512Compress
static void _BRSHA512Compress(uint64_t *r, uint64_t *x)
{
static const uint64_t k[] = {
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc, 0x3956c25bf348b538,
0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118, 0xd807aa98a3030242, 0x12835b0145706fbe,
0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2, 0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235,
0xc19bf174cf692694, 0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5, 0x983e5152ee66dfab,
0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4, 0xc6e00bf33da88fc2, 0xd5a79147930aa725,
0x06ca6351e003826f, 0x142929670a0e6e70, 0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed,
0x53380d139d95b3df, 0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,
0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30, 0xd192e819d6ef5218,
0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8, 0x19a4c116b8d2d0c8, 0x1e376c085141ab53,
0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8, 0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373,
0x682e6ff3d6b2b8a3, 0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,
0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b, 0xca273eceea26619c,
0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178, 0x06f067aa72176fba, 0x0a637dc5a2c898a6,
0x113f9804bef90dae, 0x1b710b35131c471b, 0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc,
0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817
};
int i;
uint64_t a = r[0], b = r[1], c = r[2], d = r[3], e = r[4], f = r[5], g = r[6], h = r[7], t1, t2, w[80];
for (i = 0; i < 16; i++) w[i] = be64(x[i]);
for (; i < 80; i++) w[i] = S3(w[i - 2]) + w[i - 7] + S2(w[i - 15]) + w[i - 16];
for (i = 0; i < 80; i++) {
t1 = h + S1(e) + ch(e, f, g) + k[i] + w[i];
t2 = S0(a) + maj(a, b, c);
h = g, g = f, f = e, e = d + t1, d = c, c = b, b = a, a = t1 + t2;
}
r[0] += a, r[1] += b, r[2] += c, r[3] += d, r[4] += e, r[5] += f, r[6] += g, r[7] += h;
var_clean(&a, &b, &c, &d, &e, &f, &g, &h, &t1, &t2);
mem_clean(w, sizeof(w));
}
示例7: test
void test(int M)
{
/* Scattering iterators. */
int c1, c2;
/* Original iterators. */
int i, j, k;
if (M >= 2) {
for (c2=2;c2<=M;c2++) {
for (j=2;j<=M;j++) {
S2(1,j,c2) ;
}
}
}
for (c1=2;c1<=M-1;c1++) {
for (c2=c1+1;c2<=M;c2++) {
for (j=1;j<=c1-1;j++) {
S1(c1,j,c2) ;
}
for (j=c1+1;j<=M;j++) {
S2(c1,j,c2) ;
}
}
}
}
示例8: pi_deleglise_rivat_parallel1
/// Calculate the number of primes below x using the
/// Deleglise-Rivat algorithm.
/// Run time: O(x^(2/3) / (log x)^2) operations, O(x^(1/3) * (log x)^3) space.
///
int64_t pi_deleglise_rivat_parallel1(int64_t x, int threads)
{
if (x < 2)
return 0;
double alpha = get_alpha(x, 0.0017154, -0.0508992, 0.483613, 0.0672202);
int64_t x13 = iroot<3>(x);
int64_t y = (int64_t) (x13 * alpha);
int64_t z = x / y;
int64_t p2 = P2(x, y, threads);
vector<int32_t> mu = generate_moebius(y);
vector<int32_t> lpf = generate_least_prime_factors(y);
vector<int32_t> primes = generate_primes(y);
int64_t pi_y = pi_bsearch(primes, y);
int64_t c = PhiTiny::get_c(y);
int64_t s1 = S1(x, y, c, threads);
int64_t s2 = S2(x, y, z, c, primes, lpf, mu, threads);
int64_t phi = s1 + s2;
int64_t sum = phi + pi_y - 1 - p2;
return sum;
}
示例9: main
int main()
{
init_arrays();
double annot_t_start=0, annot_t_end=0, annot_t_total=0;
int annot_i;
for (annot_i=0; annot_i<REPS; annot_i++)
{
annot_t_start = rtclock();
int t, i, j, k, l, m, n,ii,jj;
#define S1(zT0,zT1,t,j) {ey[0][j]=t;}
#define S2(zT0,zT1,zT2,t,i,j) {ey[i][j]=ey[i][j]-((double)(1))/2*(hz[i][j]-hz[i-1][j]);}
#define S3(zT0,zT1,zT2,t,i,j) {ex[i][j]=ex[i][j]-((double)(1))/2*(hz[i][j]-hz[i][j-1]);}
#define S4(zT0,zT1,zT2,t,i,j) {hz[i][j]=hz[i][j]-((double)(7))/10*(ey[1+i][j]+ex[i][1+j]-ex[i][j]-ey[i][j]);}
int c1, c2, c3, c4, c5, c6, c7;
register int lbv, ubv;
for (c1=0;c1<=floord(tmax-1,32);c1++) {
for (c2=max(ceild(32*c1-31,32),0);c2<=min(floord(tmax+ny-1,32),floord(32*c1+ny+31,32));c2++) {
for (c3=max(max(max(max(ceild(32*c2-ny-30,32),0),ceild(64*c1-32*c2-61,32)),ceild(32*c1-31,32)),ceild(32*c1-992*c2-1891,992));c3<=min(min(floord(32*c2+nx+30,32),floord(tmax+nx-1,32)),floord(32*c1+nx+31,32));c3++) {
if ((c1 <= floord(32*c3-nx,32)) && (c2 <= floord(32*c3-nx+ny,32)) && (c3 >= ceild(nx,32))) {
for (c5=max(32*c3-nx+1,32*c2);c5<=min(32*c2+31,32*c3-nx+ny);c5++) {
S4(c1,-c1+c3,-c1+c2,32*c3-nx,nx-1,-32*c3+c5+nx-1) ;
}
}
if ((c1 <= floord(32*c2-ny,32)) && (c2 >= max(ceild(32*c3-nx+ny+1,32),ceild(ny,32)))) {
for (c6=max(32*c3,32*c2-ny+1);c6<=min(32*c2+nx-ny,32*c3+31);c6++) {
S4(c1,-c1+c3,-c1+c2,32*c2-ny,-32*c2+c6+ny-1,ny-1) ;
}
}
if (c1 == c3) {
for (c4=max(max(32*c2-ny+1,0),32*c3);c4<=min(min(32*c3+30,32*c2-ny+31),tmax-1);c4++) {
for (c5=32*c2;c5<=c4+ny-1;c5++) {
S1(c1,-c1+c2,c4,-c4+c5) ;
S3(c1,0,-c1+c2,c4,0,-c4+c5) ;
for (c6=c4+1;c6<=32*c3+31;c6++) {
S2(c1,0,-c1+c2,c4,-c4+c6,-c4+c5) ;
S3(c1,0,-c1+c2,c4,-c4+c6,-c4+c5) ;
S4(c1,0,-c1+c2,c4,-c4+c6-1,-c4+c5-1) ;
}
}
for (c6=c4+1;c6<=32*c3+31;c6++) {
S4(c1,0,-c1+c2,c4,-c4+c6-1,ny-1) ;
}
}
}
if (c1 == c3) {
for (c4=max(max(0,32*c3),32*c2-ny+32);c4<=min(min(tmax-1,32*c3+30),32*c2-1);c4++) {
for (c5=32*c2;c5<=32*c2+31;c5++) {
S1(c1,-c1+c2,c4,-c4+c5) ;
S3(c1,0,-c1+c2,c4,0,-c4+c5) ;
for (c6=c4+1;c6<=32*c3+31;c6++) {
S2(c1,0,-c1+c2,c4,-c4+c6,-c4+c5) ;
S3(c1,0,-c1+c2,c4,-c4+c6,-c4+c5) ;
S4(c1,0,-c1+c2,c4,-c4+c6-1,-c4+c5-1) ;
}
}
}
}
if (c1 == c3) {
for (c4=max(max(32*c2,0),32*c3);c4<=min(min(tmax-1,32*c3+30),32*c2+30);c4++) {
S1(c1,-c1+c2,c4,0) ;
for (c6=c4+1;c6<=32*c3+31;c6++) {
S2(c1,0,-c1+c2,c4,-c4+c6,0) ;
}
for (c5=c4+1;c5<=32*c2+31;c5++) {
S1(c1,-c1+c2,c4,-c4+c5) ;
S3(c1,0,-c1+c2,c4,0,-c4+c5) ;
for (c6=c4+1;c6<=32*c3+31;c6++) {
S2(c1,0,-c1+c2,c4,-c4+c6,-c4+c5) ;
S3(c1,0,-c1+c2,c4,-c4+c6,-c4+c5) ;
S4(c1,0,-c1+c2,c4,-c4+c6-1,-c4+c5-1) ;
}
}
}
}
for (c4=max(max(max(32*c1,0),32*c2-ny+1),32*c3-nx+1);c4<=min(min(min(32*c3-nx+31,32*c2-ny+31),32*c1+31),tmax-1);c4++) {
for (c5=32*c2;c5<=c4+ny-1;c5++) {
for (c6=32*c3;c6<=c4+nx-1;c6++) {
S2(c1,-c1+c3,-c1+c2,c4,-c4+c6,-c4+c5) ;
S3(c1,-c1+c3,-c1+c2,c4,-c4+c6,-c4+c5) ;
S4(c1,-c1+c3,-c1+c2,c4,-c4+c6-1,-c4+c5-1) ;
}
S4(c1,-c1+c3,-c1+c2,c4,nx-1,-c4+c5-1) ;
}
for (c6=32*c3;c6<=c4+nx;c6++) {
S4(c1,-c1+c3,-c1+c2,c4,-c4+c6-1,ny-1) ;
}
}
for (c4=max(max(max(32*c1,0),32*c3-nx+1),32*c2-ny+32);c4<=min(min(min(tmax-1,32*c1+31),32*c2-1),32*c3-nx+31);c4++) {
for (c5=32*c2;c5<=32*c2+31;c5++) {
for (c6=32*c3;c6<=c4+nx-1;c6++) {
//.........这里部分代码省略.........
示例10: sha256d_ms
//.........这里部分代码省略.........
W[20] = S[20];
W[22] = S[22];
W[23] = S[23];
W[24] = S[24];
W[30] = S[30];
W[31] = S[31];
memcpy(S + 8, sha256d_hash1 + 8, 32);
S[16] = s1(sha256d_hash1[14]) + sha256d_hash1[ 9] + s0(S[ 1]) + S[ 0];
S[17] = s1(sha256d_hash1[15]) + sha256d_hash1[10] + s0(S[ 2]) + S[ 1];
S[18] = s1(S[16]) + sha256d_hash1[11] + s0(S[ 3]) + S[ 2];
S[19] = s1(S[17]) + sha256d_hash1[12] + s0(S[ 4]) + S[ 3];
S[20] = s1(S[18]) + sha256d_hash1[13] + s0(S[ 5]) + S[ 4];
S[21] = s1(S[19]) + sha256d_hash1[14] + s0(S[ 6]) + S[ 5];
S[22] = s1(S[20]) + sha256d_hash1[15] + s0(S[ 7]) + S[ 6];
S[23] = s1(S[21]) + S[16] + s0(sha256d_hash1[ 8]) + S[ 7];
S[24] = s1(S[22]) + S[17] + s0(sha256d_hash1[ 9]) + sha256d_hash1[ 8];
S[25] = s1(S[23]) + S[18] + s0(sha256d_hash1[10]) + sha256d_hash1[ 9];
S[26] = s1(S[24]) + S[19] + s0(sha256d_hash1[11]) + sha256d_hash1[10];
S[27] = s1(S[25]) + S[20] + s0(sha256d_hash1[12]) + sha256d_hash1[11];
S[28] = s1(S[26]) + S[21] + s0(sha256d_hash1[13]) + sha256d_hash1[12];
S[29] = s1(S[27]) + S[22] + s0(sha256d_hash1[14]) + sha256d_hash1[13];
S[30] = s1(S[28]) + S[23] + s0(sha256d_hash1[15]) + sha256d_hash1[14];
S[31] = s1(S[29]) + S[24] + s0(S[16]) + sha256d_hash1[15];
for (i = 32; i < 60; i += 2) {
S[i] = s1(S[i - 2]) + S[i - 7] + s0(S[i - 15]) + S[i - 16];
S[i+1] = s1(S[i - 1]) + S[i - 6] + s0(S[i - 14]) + S[i - 15];
}
S[60] = s1(S[58]) + S[53] + s0(S[45]) + S[44];
sha256_init(hash);
RNDr(hash, S, 0);
RNDr(hash, S, 1);
RNDr(hash, S, 2);
RNDr(hash, S, 3);
RNDr(hash, S, 4);
RNDr(hash, S, 5);
RNDr(hash, S, 6);
RNDr(hash, S, 7);
RNDr(hash, S, 8);
RNDr(hash, S, 9);
RNDr(hash, S, 10);
RNDr(hash, S, 11);
RNDr(hash, S, 12);
RNDr(hash, S, 13);
RNDr(hash, S, 14);
RNDr(hash, S, 15);
RNDr(hash, S, 16);
RNDr(hash, S, 17);
RNDr(hash, S, 18);
RNDr(hash, S, 19);
RNDr(hash, S, 20);
RNDr(hash, S, 21);
RNDr(hash, S, 22);
RNDr(hash, S, 23);
RNDr(hash, S, 24);
RNDr(hash, S, 25);
RNDr(hash, S, 26);
RNDr(hash, S, 27);
RNDr(hash, S, 28);
RNDr(hash, S, 29);
RNDr(hash, S, 30);
RNDr(hash, S, 31);
RNDr(hash, S, 32);
RNDr(hash, S, 33);
RNDr(hash, S, 34);
RNDr(hash, S, 35);
RNDr(hash, S, 36);
RNDr(hash, S, 37);
RNDr(hash, S, 38);
RNDr(hash, S, 39);
RNDr(hash, S, 40);
RNDr(hash, S, 41);
RNDr(hash, S, 42);
RNDr(hash, S, 43);
RNDr(hash, S, 44);
RNDr(hash, S, 45);
RNDr(hash, S, 46);
RNDr(hash, S, 47);
RNDr(hash, S, 48);
RNDr(hash, S, 49);
RNDr(hash, S, 50);
RNDr(hash, S, 51);
RNDr(hash, S, 52);
RNDr(hash, S, 53);
RNDr(hash, S, 54);
RNDr(hash, S, 55);
RNDr(hash, S, 56);
hash[2] += hash[6] + S1(hash[3]) + Ch(hash[3], hash[4], hash[5])
+ S[57] + sha256_k[57];
hash[1] += hash[5] + S1(hash[2]) + Ch(hash[2], hash[3], hash[4])
+ S[58] + sha256_k[58];
hash[0] += hash[4] + S1(hash[1]) + Ch(hash[1], hash[2], hash[3])
+ S[59] + sha256_k[59];
hash[7] += hash[3] + S1(hash[0]) + Ch(hash[0], hash[1], hash[2])
+ S[60] + sha256_k[60]
+ sha256_h[7];
}
示例11: sha1_core
void
sha1_core(const uint32_t M[16], uint32_t hash_value[5]) {
uint32_t H0;
uint32_t H1;
uint32_t H2;
uint32_t H3;
uint32_t H4;
uint32_t W[80];
uint32_t A, B, C, D, E, TEMP;
int t;
/* copy hash_value into H0, H1, H2, H3, H4 */
H0 = hash_value[0];
H1 = hash_value[1];
H2 = hash_value[2];
H3 = hash_value[3];
H4 = hash_value[4];
/* copy/xor message into array */
W[0] = bswap_32(M[0]);
W[1] = bswap_32(M[1]);
W[2] = bswap_32(M[2]);
W[3] = bswap_32(M[3]);
W[4] = bswap_32(M[4]);
W[5] = bswap_32(M[5]);
W[6] = bswap_32(M[6]);
W[7] = bswap_32(M[7]);
W[8] = bswap_32(M[8]);
W[9] = bswap_32(M[9]);
W[10] = bswap_32(M[10]);
W[11] = bswap_32(M[11]);
W[12] = bswap_32(M[12]);
W[13] = bswap_32(M[13]);
W[14] = bswap_32(M[14]);
W[15] = bswap_32(M[15]);
TEMP = W[13] ^ W[8] ^ W[2] ^ W[0]; W[16] = S1(TEMP);
TEMP = W[14] ^ W[9] ^ W[3] ^ W[1]; W[17] = S1(TEMP);
TEMP = W[15] ^ W[10] ^ W[4] ^ W[2]; W[18] = S1(TEMP);
TEMP = W[16] ^ W[11] ^ W[5] ^ W[3]; W[19] = S1(TEMP);
TEMP = W[17] ^ W[12] ^ W[6] ^ W[4]; W[20] = S1(TEMP);
TEMP = W[18] ^ W[13] ^ W[7] ^ W[5]; W[21] = S1(TEMP);
TEMP = W[19] ^ W[14] ^ W[8] ^ W[6]; W[22] = S1(TEMP);
TEMP = W[20] ^ W[15] ^ W[9] ^ W[7]; W[23] = S1(TEMP);
TEMP = W[21] ^ W[16] ^ W[10] ^ W[8]; W[24] = S1(TEMP);
TEMP = W[22] ^ W[17] ^ W[11] ^ W[9]; W[25] = S1(TEMP);
TEMP = W[23] ^ W[18] ^ W[12] ^ W[10]; W[26] = S1(TEMP);
TEMP = W[24] ^ W[19] ^ W[13] ^ W[11]; W[27] = S1(TEMP);
TEMP = W[25] ^ W[20] ^ W[14] ^ W[12]; W[28] = S1(TEMP);
TEMP = W[26] ^ W[21] ^ W[15] ^ W[13]; W[29] = S1(TEMP);
TEMP = W[27] ^ W[22] ^ W[16] ^ W[14]; W[30] = S1(TEMP);
TEMP = W[28] ^ W[23] ^ W[17] ^ W[15]; W[31] = S1(TEMP);
/* process the remainder of the array */
for (t=32; t < 80; t++) {
TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
W[t] = S1(TEMP);
}
A = H0; B = H1; C = H2; D = H3; E = H4;
for (t=0; t < 20; t++) {
TEMP = S5(A) + f0(B,C,D) + E + W[t] + SHA_K0;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
for ( ; t < 40; t++) {
TEMP = S5(A) + f1(B,C,D) + E + W[t] + SHA_K1;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
for ( ; t < 60; t++) {
TEMP = S5(A) + f2(B,C,D) + E + W[t] + SHA_K2;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
for ( ; t < 80; t++) {
TEMP = S5(A) + f3(B,C,D) + E + W[t] + SHA_K3;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
hash_value[0] = H0 + A;
hash_value[1] = H1 + B;
hash_value[2] = H2 + C;
hash_value[3] = H3 + D;
hash_value[4] = H4 + E;
return;
}
示例12: TEST
TEST( Commission , EquivalenceClass )
{
srand(time(NULL));
for( int times = 0 ; times < 100000 ; ++times )
{
vector<tuple<int,int,int>> dataSets;
int sets = rand()%10+5;
bool VALID_FLAG = true;
bool TERM_FLAG = false;
bool LOCK_ERR_FLAG = false ,STOCK_ERR_FLAG = false ,BARREL_ERR_FLAG = false;
for( int i = 0 ; i < sets ; ++i )
{
int l = num() , s = num() , b = num();
if( !L1(l) || !S1(s) || !B1(b) )
VALID_FLAG = false;
if( L2(l) ) TERM_FLAG = true;
if( L3(l) || L4(l) ) LOCK_ERR_FLAG = true;
if( S2(s) || S3(s) ) STOCK_ERR_FLAG = true;
if( B2(b) || B3(b) ) BARREL_ERR_FLAG = true;
dataSets.emplace_back(make_tuple(l,s,b));
if( TERM_FLAG ) break;
}
//add terminator
if( !TERM_FLAG )
if( num() % 4 != 3 ) // 75% chance
{
dataSets.emplace_back(make_tuple(-1,0,0));
TERM_FLAG = true;
}
else
VALID_FLAG = false;
// for any error, result will be invalid
if( LOCK_ERR_FLAG || STOCK_ERR_FLAG || BARREL_ERR_FLAG || !TERM_FLAG )
VALID_FLAG = false;
double result = retrieve(dataSets);
if( VALID_FLAG == true )
{
ASSERT_TRUE( 0 <= result ) << "Result is Valid but return error";
}
else
{
// error code must match the flag
switch(cms_error_code) {
case TERM_ERROR:
ASSERT_TRUE(!TERM_FLAG);
break;
case LOCK_ERROR:
ASSERT_TRUE(LOCK_ERR_FLAG);
break;
case STOCK_ERROR:
ASSERT_TRUE(STOCK_ERR_FLAG);
break;
case BARREL_ERROR:
ASSERT_TRUE(BARREL_ERR_FLAG);
break;
case OK:
break;
default:
ASSERT_TRUE(false) << "Fatel Error ,Code = " << cms_error_code << endl;
}
}
}
}
示例13: test_register_filter_with_null_clsMinorType
static void test_register_filter_with_null_clsMinorType(void)
{
IFilterMapper2 *pMapper = NULL;
HRESULT hr;
REGFILTER2 rgf2;
REGFILTERPINS rgPins;
REGFILTERPINS2 rgPins2;
REGPINTYPES rgPinType;
static WCHAR wszPinName[] = {'P', 'i', 'n', 0 };
static const WCHAR wszFilterName1[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '1', 0 };
static const WCHAR wszFilterName2[] = {'T', 'e', 's', 't', 'f', 'i', 'l', 't', 'e', 'r', '2', 0 };
CLSID clsidFilter1;
CLSID clsidFilter2;
hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
&IID_IFilterMapper2, (LPVOID*)&pMapper);
ok(hr == S_OK, "CoCreateInstance failed with %x\n", hr);
if (FAILED(hr)) goto out;
hr = CoCreateGuid(&clsidFilter1);
ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr);
hr = CoCreateGuid(&clsidFilter2);
ok(hr == S_OK, "CoCreateGuid failed with %x\n", hr);
rgPinType.clsMajorType = &GUID_NULL;
/* Make sure quartz accepts it without crashing */
rgPinType.clsMinorType = NULL;
/* Test with pin descript version 1 */
ZeroMemory(&rgf2, sizeof(rgf2));
rgf2.dwVersion = 1;
rgf2.dwMerit = MERIT_UNLIKELY;
S1(U(rgf2)).cPins = 1;
S1(U(rgf2)).rgPins = &rgPins;
rgPins.strName = wszPinName;
rgPins.bRendered = 1;
rgPins.bOutput = 0;
rgPins.bZero = 0;
rgPins.bMany = 0;
rgPins.clsConnectsToFilter = NULL;
rgPins.strConnectsToPin = NULL;
rgPins.nMediaTypes = 1;
rgPins.lpMediaType = &rgPinType;
hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter1, wszFilterName1, NULL,
&CLSID_LegacyAmFilterCategory, NULL, &rgf2);
if (hr == E_ACCESSDENIED)
{
skip("Not authorized to register filters\n");
goto out;
}
ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr);
hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter1);
ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr);
/* Test with pin descript version 2 */
ZeroMemory(&rgf2, sizeof(rgf2));
rgf2.dwVersion = 2;
rgf2.dwMerit = MERIT_UNLIKELY;
S2(U(rgf2)).cPins2 = 1;
S2(U(rgf2)).rgPins2 = &rgPins2;
rgPins2.dwFlags = REG_PINFLAG_B_RENDERER;
rgPins2.cInstances = 1;
rgPins2.nMediaTypes = 1;
rgPins2.lpMediaType = &rgPinType;
rgPins2.nMediums = 0;
rgPins2.lpMedium = NULL;
rgPins2.clsPinCategory = NULL;
hr = IFilterMapper2_RegisterFilter(pMapper, &clsidFilter2, wszFilterName2, NULL,
&CLSID_LegacyAmFilterCategory, NULL, &rgf2);
ok(hr == S_OK, "IFilterMapper2_RegisterFilter failed with %x\n", hr);
hr = IFilterMapper2_UnregisterFilter(pMapper, &CLSID_LegacyAmFilterCategory, NULL, &clsidFilter2);
ok(hr == S_OK, "FilterMapper_UnregisterFilter failed with %x\n", hr);
out:
if (pMapper) IFilterMapper2_Release(pMapper);
}
示例14: sha1_final
void
sha1_final(sha1_ctx_t *ctx, uint32_t *output) {
uint32_t A, B, C, D, E, TEMP;
uint32_t W[80];
int i, t;
/*
* process the remaining octets_in_buffer, padding and terminating as
* necessary
*/
{
int tail = ctx->octets_in_buffer % 4;
/* copy/xor message into array */
for (i=0; i < (ctx->octets_in_buffer+3)/4; i++)
W[i] = bswap_32(ctx->M[i]); /* why no bswap_32() here? - DAM */
/* set the high bit of the octet immediately following the message */
switch (tail) {
case (3):
W[i-1] = (bswap_32(ctx->M[i-1]) & 0xffffff00) | 0x80;
W[i] = 0x0;
break;
case (2):
W[i-1] = (bswap_32(ctx->M[i-1]) & 0xffff0000) | 0x8000;
W[i] = 0x0;
break;
case (1):
W[i-1] = (bswap_32(ctx->M[i-1]) & 0xff000000) | 0x800000;
W[i] = 0x0;
break;
case (0):
W[i] = 0x80000000;
break;
}
/* zeroize remaining words */
for (i++ ; i < 15; i++)
W[i] = 0x0;
/*
* if there is room at the end of the word array, then set the
* last word to the bit-length of the message; otherwise, set that
* word to zero and then we need to do one more run of the
* compression algo.
*/
if (ctx->octets_in_buffer < 56)
W[15] = ctx->num_bits_in_msg;
else
W[15] = 0x0;
/* process the word array */
for (t=16; t < 80; t++) {
TEMP = W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16];
W[t] = S1(TEMP);
}
A = ctx->H[0];
B = ctx->H[1];
C = ctx->H[2];
D = ctx->H[3];
E = ctx->H[4];
for (t=0; t < 20; t++) {
TEMP = S5(A) + f0(B,C,D) + E + W[t] + SHA_K0;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
for ( ; t < 40; t++) {
TEMP = S5(A) + f1(B,C,D) + E + W[t] + SHA_K1;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
for ( ; t < 60; t++) {
TEMP = S5(A) + f2(B,C,D) + E + W[t] + SHA_K2;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
for ( ; t < 80; t++) {
TEMP = S5(A) + f3(B,C,D) + E + W[t] + SHA_K3;
E = D; D = C; C = S30(B); B = A; A = TEMP;
}
ctx->H[0] += A;
ctx->H[1] += B;
ctx->H[2] += C;
ctx->H[3] += D;
ctx->H[4] += E;
}
debug_print(mod_sha1, "(final) running sha1_core()", NULL);
if (ctx->octets_in_buffer >= 56) {
debug_print(mod_sha1, "(final) running sha1_core() again", NULL);
/* we need to do one final run of the compression algo */
/*
* set initial part of word array to zeros, and set the
* final part to the number of bits in the message
*/
//.........这里部分代码省略.........