Esempio n. 1
0
/// tests Matrix4 multiply method
TEST_F(Math_Matrix4Tests, Multiply)
{
    // Identity test
    matrixSet(i, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
    matrixSet(m, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
    Matrix4 i_check(i);
    Matrix4 m_check(m);
    actual.multiply(i, m);
    ASSERT_MATRIX_EQ(m, actual);

    // Identity test 2
    actual.multiply(m, i);
    ASSERT_MATRIX_EQ(m, actual);

    // setup matrices
    matrixSet(m1, 5,-71,-13,86,-86,-8,-62,8,-69,-106,81,125,-1,-52,84,47);
    Matrix4 m1_check(m1);
    matrixSet(m2, -92,-59,-55,-91,47,-86,-93,-32,19,126,44,92,32,112,119,-94);
    Matrix4 m2_check(m2);
    matrixSet(expected, 8500,17566,-7245,-19536,14080,8873,-5500,-9775,-13869,
              -11805,3233,12466,-17589,-10894,-5617,14105);
              
    // perform test
    actual.multiply(m1,m2);
    ASSERT_MATRIX_EQ(expected, actual);
    
    // perform tests to ensure read-only memory didn't fail
    ASSERT_MATRIX_EQ(m1_check, m1);
    ASSERT_MATRIX_EQ(m2_check, m2);
}
Esempio n. 2
0
int main(int argc, char** argv)
{
	double a = 1.1;
	int i = 2;

	double d1, d2;
	int i1, i2;

	/* write out data sizes */
	printf("data sizes:\n");
/*	printf("sizeof(bool) = %d\n", sizeof(bool)); */
	printf("sizeof(char) = %d\n", sizeof(char));
	printf("sizeof(int) = %d\n", sizeof(int));
	printf("sizeof(long int) = %d\n", sizeof(long int));
	printf("sizeof(float) = %d\n", sizeof(float));
	printf("sizeof(double) = %d\n", sizeof(double));
	printf("sizeof(void*) = %d\n", sizeof(void*));
	printf("\n");
	
	d1 = d2 = cos(0.1);
	i1 = i2 = 94117;
	
	printf("start: d = %15.12lf, i = %5d\n", d1, i1);
	
	FORTRAN_NAME(double_it)(&d1, &i1);
	d2 *= 2.0;
	i2 *= 2;
	printf("double an int and a double: ");
	if (d_check(d1,d2) && i_check(i1,i2))
		printf("PASS\n");
	else
		printf("FAIL\n");
	
	FORTRAN_NAME(sqrt_f)(&d1);
	d2 = sqrt(d2);
	printf("sqrt of double: ");
	if (d_check(d1,d2))
		printf("PASS\n");
	else
		printf("FAIL\n");

	FORTRAN_NAME(sqrt_f_c)(&d1);
	d2 = sqrt(d2);
	printf("sqrt of double in C called from Fortran: ");
	if (d_check(d1,d2))
		printf("PASS\n");
	else
		printf("FAIL\n");

	printf("end: d = %15.12lf, i = %5d\n", d1, i1);

	printf("print values from Fortran functions:\n");
	FORTRAN_NAME(print_double)(&d1);
	FORTRAN_NAME(print_int)(&i1);
		
	return 0;
}
Esempio n. 3
0
int main (int, char**)
{
	cout.precision(12);
	cout.setf(ios::showpoint);
	cout.setf(ios::right, ios::adjustfield);
	cout.setf(ios::scientific, ios::floatfield);

	/* write out data sizes */
	cout << "data sizes:\n"
	     << "sizeof(bool) = " << sizeof(bool) << '\n'
	     << "sizeof(char) = " << sizeof(char) << '\n'
	     << "sizeof(int) = " << sizeof(int) << '\n'
	     << "sizeof(long int) = " << sizeof(long int) << '\n'
	     << "sizeof(float) = " << sizeof(float) << '\n'
	     << "sizeof(double) = " << sizeof(double) << '\n'
	     << "sizeof(long double) = " << sizeof(long double) << '\n'
	     << "sizeof(void*) = " << sizeof(void*) << "\n\n";

	int wd = 15;
	int wi = 5;

	double d1, d2;
	int i1, i2;
	
	d1 = d2 = cos(0.1);
	i1 = i2 = 94117;
	
	cout << "start: d = " << setw(wd) << d1 << ", i = " << setw(wi) << i1 << '\n';
	
	FORTRAN_NAME(double_it)(&d1, &i1);
	d2 *= 2.0;
	i2 *= 2;
	cout << "double an int and a double: ";
	if (d_check(d1,d2) && i_check(i1,i2))
		cout << "PASS" << endl;
	else
		cout << "FAIL" << endl;
	
	FORTRAN_NAME(sqrt_f)(&d1);
	d2 = sqrt(d2);
	cout << "sqrt of double: ";
	if (d_check(d1,d2))
		cout << "PASS" << endl;
	else
		cout << "FAIL" << endl;

	FORTRAN_NAME(sqrt_f_c)(&d1);
	d2 = sqrt(d2);
	cout << "sqrt of double in C called from Fortran: ";
	if (d_check(d1,d2))
		cout << "PASS" << endl;
	else
		cout << "FAIL" << endl;

	cout << "end: d = " << setw(wd) << d1 << ", i = " << setw(wi) << i1 << '\n';

	cout << "print values from Fortran functions:\n";
	FORTRAN_NAME(print_double)(&d1);
	FORTRAN_NAME(print_int)(&i1);
		
	cout << "Done." << endl;
	return 0;
}