예제 #1
0
int main(int argc, char* argv[]) {
    int i, j;
    int n = (SIZE);
    double A[(SIZE) * (SIZE)] = {0};
    double *L = NULL;
    FILE *fp = NULL;
    char filename[150];

    sprintf(filename, "%s/matrices/%d", PATH, SIZE);
    fp = fopen(filename, "r");
    if (fp == NULL) {
        return 1;
    }

    for (i = 0; i < n * n; ++i) {
        fscanf(fp, "%lf", A + i);  
    }

    start_clock();
    start_papi();
    L = cholesky(A, n);
    stop_papi();
    stop_clock();

    double checksum = 0.0;
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            if (j <= i) {
                checksum += i + j + L[IL(i, j)];
            } else {
                checksum += i + j;
            }
        }
    }

    printf("Size: %d\n", n);
    printf("Checksum: %lf\n", checksum);
    return 0;
}
예제 #2
0
//数组AMOUNT中第一个数为分组密码算法的数量,以后依次为流密码,HASH,MAC,RNG的数量
extern const int AMOUNTS[] = {21,6,18,6,2};
extern const Cipher CIPHERS[] = {
	BlockInfo("AES",KL(AES),BS(AES)),BlockInfo("Blowfish",KL(Blowfish),BS(Blowfish)),
	BlockInfo("Camellia",KL(Camellia),BS(Camellia)),BlockInfo("CAST256",KL(CAST256),BS(CAST256)),
	BlockInfo("DES",KL(DES),BS(DES)),BlockInfo("MARS",KL(MARS),BS(MARS)),
	BlockInfo("IDEA",KL(IDEA),BS(IDEA)),BlockInfo("RC5",KL(RC5),BS(RC5)),
	BlockInfo("RC6",KL(RC6),BS(RC6)),BlockInfo("SEED",KL(SEED),BS(SEED)),
	BlockInfo("Serpent",KL(Serpent),BS(Serpent)),BlockInfo("SHACAL2",KL(SHACAL2),BS(SHACAL2)),
	BlockInfo("SKIPJACK",KL(SKIPJACK),BS(SKIPJACK)),BlockInfo("TEA",KL(TEA),BS(TEA)),
	BlockInfo("Twofish",KL(Twofish),BS(Twofish)),BlockInfo("XTEA",KL(XTEA),BS(XTEA)),
	BlockInfo("DES_EDE3",KL(DES_EDE3),BS(DES_EDE3)),BlockInfo("GOST",KL(GOST),BS(GOST)),
	BlockInfo("SHARK",KL(SHARK),BS(SHARK)),BlockInfo("Square",KL(Square),BS(Square)),
	BlockInfo("ThreeWay",KL(ThreeWay),BS(ThreeWay)),

	StreamInfo("Sosemanuk",KL(Sosemanuk),IL(Sosemanuk)),
	StreamInfo("Salsa20",KL(Salsa20),IL(Salsa20)),
	StreamInfo("XSalsa20",KL(XSalsa20),IL(XSalsa20)),
	StreamInfo("SEAL",KL(SEAL<>),IL(SEAL<>)),
	StreamInfo("PanamaCipher",KL(PanamaCipher<>),IL(PanamaCipher<>)),
	StreamInfo("RC4",KL(Weak::ARC4),IL(Weak::ARC4)),

	HashInfo("MD2",DS(Weak::MD2)),HashInfo("MD4",DS(Weak::MD4)),
	HashInfo("MD5",DS(Weak::MD5)),HashInfo("SHA1",DS(SHA1)),
	HashInfo("SHA256",DS(SHA256)),HashInfo("SHA224",DS(SHA224)),
	HashInfo("SHA512",DS(SHA512)),HashInfo("SHA384",DS(SHA384)),
	HashInfo("SHA3_224",DS(SHA3_224)),HashInfo("SHA3_256",DS(SHA3_256)),
	HashInfo("SHA3_384",DS(SHA3_384)),HashInfo("SHA3_512",DS(SHA3_512)),
	HashInfo("Tiger",DS(Tiger)),HashInfo("RIPEMD160",DS(RIPEMD160)),
	HashInfo("RIPEMD320",DS(RIPEMD320)),HashInfo("RIPEMD128",DS(RIPEMD128)),
	HashInfo("RIPEMD256",DS(RIPEMD256)),HashInfo("Whirlpool",DS(Whirlpool)),
예제 #3
0
double* cholesky(double *A, int n) {
    register int i, j, k;
    double s, a;
    double *L = (double*)calloc(n * (n + 1), sizeof(double));
    for (i = 0; i < n; ++i) {
        for (j = 0; j < i; ++j) {
            a = A[IA(i, j)];
            for (k = 0; k < j; k += 4) {
                a -= L[IL(i, k)] * L[IL(j, k)];
                a -= L[IL(i, k + 1)] * L[IL(j, k + 1)];
                a -= L[IL(i, k + 2)] * L[IL(j, k + 2)];
                a -= L[IL(i, k + 3)] * L[IL(j, k + 3)];
            }

            L[IL(i, j)] = a / L[IL(j, j)];
        }

        a = A[IA(i, i)];
        for (k = 0; k < i; k += 4) {
            a -= L[IL(i, k)] * L[IL(i, k)];
            a -= L[IL(i, k + 1)] * L[IL(i, k + 1)];
            a -= L[IL(i, k + 2)] * L[IL(i, k + 2)];
            a -= L[IL(i, k + 3)] * L[IL(i, k + 3)];
        }

        L[IL(i, i)] = sqrt(a);
    }

    return L;
}