void create_tests(float32_t eps) { int rows=4; int cols=3; int cols2=2; ambix_matrix_t matrix, *left, *right; STARTTEST(""); memset(&matrix, 0, sizeof(matrix)); left=ambix_matrix_create(); fail_if((left==NULL), __LINE__, "failed to create left matrix"); fail_if((left->rows || left->cols), __LINE__, "created empty matrix has non-zero size"); fail_if((left!=ambix_matrix_init(rows, cols, left)), __LINE__, "initializing existing matrix* returned new matrix"); fail_if((left->rows!=rows || left->cols!=cols), __LINE__, "created matrix [%dx%d] does not match [%dx%d]", left->rows, left->cols, cols, cols2); right=ambix_matrix_init(cols, cols2, NULL); fail_if((right==NULL), __LINE__, "failed to create right matrix"); fail_if((right->rows!=cols || right->cols!=cols2), __LINE__, "created matrix [%dx%d] does not match [%dx%d]", right->rows, right->cols, cols, cols2); fail_if((&matrix!=ambix_matrix_init(rows, cols2, &matrix)), __LINE__, "initializing existing matrix returned new matrix"); fail_if((matrix.rows!=rows || matrix.cols!=cols2), __LINE__, "initialized matrix [%dx%d] does not match [%dx%d]", matrix.rows, matrix.cols, rows, cols2); ambix_matrix_deinit(&matrix); fail_if((matrix.rows || matrix.cols), __LINE__, "deinitialized matrix is non-zero"); ambix_matrix_deinit(left); fail_if((left->rows || left->cols), __LINE__, "deinitialized matrix is non-zero"); ambix_matrix_destroy(left); ambix_matrix_destroy(right); }
void mtxmul_eye_tests(float32_t eps) { float32_t errf; ambix_matrix_t *left, *result, *eye; STARTTEST(""); eye=ambix_matrix_init(4, 4, NULL); fail_if((eye!=ambix_matrix_fill(eye, AMBIX_MATRIX_IDENTITY)), __LINE__, "filling unity matrix %p did not return original matrix %p", eye); left=ambix_matrix_init(4, 2, NULL); fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_fill_data(left, resultdata_4_2), __LINE__, "filling left data failed"); result=ambix_matrix_init(4, 2, NULL); fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_fill_data(result, resultdata_4_2), __LINE__, "filling result data failed"); fail_if((result!=ambix_matrix_multiply(eye, left, result)), __LINE__, "multiplication into matrix did not return original matrix"); #if 0 matrix_print(eye); matrix_print(result); matrix_print(left); #endif errf=matrix_diff(__LINE__, left, result, eps); fail_if((errf>eps), __LINE__, "diffing matrix M with E*M returned %f (>%f)", errf, eps); ambix_matrix_destroy(left); ambix_matrix_destroy(result); ambix_matrix_destroy(eye); }
void datamul_eye_tests(float32_t eps) { float32_t errf; uint64_t frames=4096; uint32_t channels=16; float32_t*inputdata; float32_t*outputdata; float32_t freq=500; ambix_matrix_t eye = {0, 0, NULL}; STARTTEST(""); inputdata =data_sine(frames, channels, freq); outputdata=(float32_t*)malloc(sizeof(float32_t)*frames*channels); fail_if((NULL==outputdata), __LINE__, "couldn't mallocate outputdata"); ambix_matrix_init(channels, channels, &eye); ambix_matrix_fill(&eye, AMBIX_MATRIX_IDENTITY); fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(outputdata, &eye, inputdata, frames), __LINE__, "data multilplication failed"); errf=data_diff(__LINE__, inputdata, outputdata, frames*channels, eps); fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n"); matrix_print(&eye); printf("input :\n"); data_print(inputdata, frames*channels); printf("output:\n"); data_print(outputdata,frames*channels); #endif free(inputdata); free(outputdata); ambix_matrix_deinit(&eye); }
void mtx_copy(float32_t eps) { float32_t errf; ambix_matrix_t *left=NULL, *right=NULL; unsigned int i; float32_t maxeps=eps; STARTTEST("\n"); right=ambix_matrix_copy(left, NULL); fail_if((NULL!=right), __LINE__, "copying from NULL matrix erroneously succeeded"); left=ambix_matrix_create(); fail_if((left !=ambix_matrix_init(4, 3, left )), __LINE__, "initializing left matrix failed"); ambix_matrix_fill_data(left, leftdata_4_3); right=ambix_matrix_copy(left, NULL); fail_if((NULL==right), __LINE__, "copying to NULL matrix failed"); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf>0.f, __LINE__, "diffing mtx with copy0 returned %g (>%g)", errf, 0.f); right=ambix_matrix_copy(left, right); fail_if((NULL==right), __LINE__, "copying to right matrix failed"); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf>0.f, __LINE__, "diffing mtx with copy returned %g (>%g)", errf, 0.f); ambix_matrix_destroy(left); ambix_matrix_destroy(right); STOPTEST("\n"); }
void check_matrix(const char*name, ambix_matrixtype_t typ, uint32_t rows, uint32_t cols) { ambix_matrix_t*mtx=NULL; ambix_matrix_t*result=NULL; ambix_matrix_t*zeros=NULL; float32_t errf=0.f; float32_t eps=1e-20; STARTTEST(name); mtx=ambix_matrix_init(rows, cols, mtx); result=ambix_matrix_fill(mtx, typ); fail_if((result==NULL), __LINE__, "matrix_fill returned NULL"); fail_if((result!=mtx ), __LINE__, "matrix_fill did not return matrix %p (got %p)", mtx, result); zeros=ambix_matrix_init(result->rows, result->cols, zeros); zeros=ambix_matrix_fill(zeros, AMBIX_MATRIX_ZERO); errf=matrix_check_diff(name, result, zeros); if(AMBIX_MATRIX_ZERO==typ) { fail_if(!(errf<eps), __LINE__, "zero matrix non-zero (%f>%f)", errf, eps); } else { fail_if((errf<eps), __LINE__, "non-zero matrix zero (%f<%f)", errf, eps); } ambix_matrix_destroy(mtx); ambix_matrix_destroy(zeros); }
void datamul_tests(float32_t eps) { float32_t errf; float32_t*resultdata = (float32_t*)calloc(2*4, sizeof(float32_t)); float32_t*resultdataT = (float32_t*)calloc(4*2, sizeof(float32_t)); float32_t*inputdata = (float32_t*)calloc(2*3, sizeof(float32_t)); fail_if((NULL==resultdata), __LINE__, "couldn't callocate resultdata"); fail_if((NULL==resultdataT), __LINE__, "couldn't callocate resultdataT"); fail_if((NULL==inputdata), __LINE__, "couldn't callocate inputdata"); ambix_matrix_t*mtx=NULL; STARTTEST("\n"); mtx=ambix_matrix_init(4, 3, NULL); ambix_matrix_fill_data(mtx, leftdata_4_3); data_transpose(inputdata, rightdata_3_2, 3, 2); fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(resultdata, mtx, inputdata, 2), __LINE__, "data multiplication failed"); data_transpose(resultdataT, resultdata, 2, 4); errf=data_diff(__LINE__, FLOAT32, resultdataT, resultdata_4_2, 4*2, eps); if(errf>eps) { printf("matrix:\n"); matrix_print(mtx); printf("input:\n"); data_print(FLOAT32, inputdata, 3*2); printf("expected:\n"); data_print(FLOAT32, resultdata_4_2, 4*2); printf("calculated:\n"); data_print(FLOAT32, resultdataT , 4*2); } fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n");matrix_print(mtx); printf("input :\n"); data_print(FLOAT32, rightdata_3_2, 3*2); printf("output:\n"); data_print(FLOAT32, resultdata, 4*2); printf("target:\n"); data_print(FLOAT32, resultdata_4_2, 4*2); #endif if(mtx)ambix_matrix_destroy(mtx); free(resultdata); free(resultdataT); free(inputdata); STOPTEST("\n"); }
int test_defaultmatrix(const char*name, uint32_t rows, uint32_t cols, ambix_matrixtype_t mtyp, uint32_t xtrachannels, uint32_t chunksize, float32_t eps) { int result=0; ambix_matrix_t*mtx=0; STARTTEST("%s\n", name); mtx=ambix_matrix_init(rows,cols,mtx); if(!mtx)return 1; ambix_matrix_fill(mtx, mtyp); result=check_create_b2e(FILENAME_FILE, AMBIX_SAMPLEFORMAT_PCM16, mtx,xtrachannels, chunksize, FLOAT32, eps); ambix_matrix_destroy(mtx); return result; }
void mtxmul_tests(float32_t eps) { float32_t errf; ambix_matrix_t *left=NULL, *right=NULL, *result, *testresult; STARTTEST("\n"); /* fill in some test data */ left=ambix_matrix_init(4, 3, NULL); ambix_matrix_fill_data(left, leftdata_4_3); right=ambix_matrix_init(3, 2, NULL); ambix_matrix_fill_data(right, rightdata_3_2); testresult=ambix_matrix_init(4, 2, NULL); ambix_matrix_fill_data(testresult, resultdata_4_2); errf=matrix_diff(__LINE__, left, left, eps); fail_if(!(errf<eps), __LINE__, "diffing matrix with itself returned %f (>%f)", errf, eps); /* NULL multiplications */ result=ambix_matrix_multiply(NULL, NULL, NULL); fail_if(NULL!=result, __LINE__, "multiplying NULL*NULL returned success"); result=ambix_matrix_multiply(left, NULL, result); fail_if(NULL!=result, __LINE__, "multiplying left*NULL returned success"); result=ambix_matrix_multiply(NULL, left, result); fail_if(NULL!=result, __LINE__, "multiplying NULL*left returned success"); /* do some matrix multiplication */ result=ambix_matrix_multiply(left, right, NULL); fail_if((NULL==result), __LINE__, "multiply into NULL did not create matrix"); fail_if((result!=ambix_matrix_multiply(left, right, result)), __LINE__, "multiply into existing matrix returned new matrix"); #if 0 matrix_print(left); matrix_print(right); matrix_print(result); printf("------------\n"); #endif errf=matrix_diff(__LINE__, testresult, result, eps); fail_if((errf>eps), __LINE__, "diffing two results of same multiplication returned %f (>%f)", errf, eps); ambix_matrix_destroy(left); ambix_matrix_destroy(right); ambix_matrix_destroy(result); ambix_matrix_destroy(testresult); STOPTEST("\n"); }
void check_inversion(const char*name, ambix_matrixtype_t typ, uint32_t rows, uint32_t cols) { ambix_matrix_t*eye=NULL; ambix_matrix_t*result=NULL; float32_t errf; float32_t eps=1e-6; STARTTEST(name); result=inverse_matrices(typ, rows, cols); eye=ambix_matrix_init(result->rows, result->cols, eye); eye=ambix_matrix_fill(eye, AMBIX_MATRIX_IDENTITY); errf=matrix_check_diff(name, result, eye); if(!(errf<eps)){ matrix_print(result); } fail_if(!(errf<eps), __LINE__, "diffing matrices (%s) returned %g-%g=%g", name, errf, eps, errf-eps); ambix_matrix_destroy(result); ambix_matrix_destroy(eye); }
void check_create_extended(const char*path, ambix_sampleformat_t format, uint32_t chunksize, float32_t eps) { ambix_info_t info, rinfo, winfo; ambix_t*ambix=NULL; float32_t*orgambidata,*ambidata,*resultambidata; float32_t*orgotherdata,*otherdata,*resultotherdata; uint32_t framesize=441000; uint32_t ambichannels=4; uint32_t extrachannels=2; float32_t periods=20000; ambix_matrix_t eye={0,0,NULL}; const ambix_matrix_t*eye2=NULL; int64_t err64, gotframes; float32_t diff=0.; STARTTEST("\n"); printf("test using '%s' [%d] with chunks of %d and eps=%f\n", path, (int)format, (int)chunksize, eps); resultambidata=(float32_t*)calloc(ambichannels*framesize, sizeof(float32_t)); ambidata=(float32_t*)calloc(ambichannels*framesize, sizeof(float32_t)); resultotherdata=(float32_t*)calloc(extrachannels*framesize, sizeof(float32_t)); otherdata=(float32_t*)calloc(extrachannels*framesize, sizeof(float32_t)); ambix_matrix_init(ambichannels, ambichannels, &eye); ambix_matrix_fill(&eye, AMBIX_MATRIX_IDENTITY); memset(&winfo, 0, sizeof(winfo)); memset(&info, 0, sizeof(info)); info.fileformat=AMBIX_EXTENDED; info.ambichannels=ambichannels; info.extrachannels=extrachannels; info.samplerate=44100; info.sampleformat=format; memcpy(&rinfo, &info, sizeof(info)); ambix=ambix_open(path, AMBIX_WRITE, &rinfo); fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for writing", path); orgambidata=data_sine (FLOAT32, framesize, ambichannels, periods); orgotherdata=data_ramp(FLOAT32, framesize, extrachannels); //data_print(FLOAT32, orgdata, 100); fail_if((NULL==orgambidata), __LINE__, "couldn't create ambidata %dx%d sine @ %f", (int)framesize, (int)ambichannels, (float)periods); fail_if((NULL==orgotherdata), __LINE__, "couldn't create otherdata %dx%d sine @ %f", (int)framesize, (int)extrachannels, (float)periods); memcpy(ambidata, orgambidata, framesize*ambichannels*sizeof(float32_t)); memcpy(otherdata, orgotherdata, framesize*extrachannels*sizeof(float32_t)); fail_if((AMBIX_ERR_SUCCESS!=ambix_set_adaptormatrix(ambix, &eye)), __LINE__, "failed setting adaptor matrix"); if(chunksize>0) { uint32_t subframe=chunksize; uint32_t chunks = framesize/chunksize; uint32_t framesleft=framesize; uint32_t frame; printf("writing %d chunks of %d frames\n", (int)chunks, (int)chunksize); for(frame=0; frame<chunks; frame++) { err64=ambix_writef_float32(ambix, ambidata+ambichannels*frame*chunksize, otherdata+extrachannels*frame*chunksize, chunksize); fail_if((err64!=chunksize), __LINE__, "wrote only %d chunksize of %d", (int)err64, (int)chunksize); framesleft-=chunksize; } subframe=framesleft; printf("writing rest of %d frames\n", (int)subframe); err64=ambix_writef_float32(ambix, ambidata+ambichannels*frame*chunksize, otherdata+extrachannels*frame*chunksize, subframe); fail_if((err64!=subframe), __LINE__, "wrote only %d subframe of %d", (int)err64, (int)subframe); } else { err64=ambix_writef_float32(ambix, ambidata, otherdata, framesize); fail_if((err64!=framesize), __LINE__, "wrote only %d frames of %d", (int)err64, (int)framesize); } diff=data_diff(__LINE__, FLOAT32, orgambidata, ambidata, framesize*ambichannels, eps); fail_if((diff>eps), __LINE__, "ambidata diff %f > %f", diff, eps); diff=data_diff(__LINE__, FLOAT32, orgotherdata, otherdata, framesize*extrachannels, eps); fail_if((diff>eps), __LINE__, "otherdata diff %f > %f", diff, eps); fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); ambix=NULL; /* read data back */ ambix=ambix_open(path, AMBIX_READ, &rinfo); fail_if((NULL==ambix), __LINE__, "couldn't create ambix file '%s' for reading", path); fail_if((info.fileformat!=rinfo.fileformat), __LINE__, "fileformat mismatch %d!=%d", (int)info.fileformat, (int)rinfo.fileformat); fail_if((info.samplerate!=rinfo.samplerate), __LINE__, "samplerate mismatch %g!=%g", (float)info.samplerate, (float)rinfo.samplerate); fail_if((info.sampleformat!=rinfo.sampleformat), __LINE__, "sampleformat mismatch %d!=%d", (int)info.sampleformat, (int)rinfo.sampleformat); fail_if((info.ambichannels!=rinfo.ambichannels), __LINE__, "ambichannels mismatch %d!=%d", (int)info.ambichannels, (int)rinfo.ambichannels); fail_if((info.extrachannels!=rinfo.extrachannels), __LINE__, "extrachannels mismatch %d!=%d", (int)info.extrachannels, (int)rinfo.extrachannels); eye2=ambix_get_adaptormatrix(ambix); fail_if((NULL==eye2), __LINE__, "failed reading adaptor matrix"); diff=matrix_diff(__LINE__, &eye, eye2, eps); fail_if((diff>eps), __LINE__, "adaptormatrix diff %f > %f", diff, eps); gotframes=0; do { //err64=ambix_readf_float32(ambix, resultambidata, resultotherdata, framesize); err64=ambix_readf_float32(ambix, resultambidata +(gotframes*ambichannels ), resultotherdata+(gotframes*extrachannels), (framesize-gotframes)); fail_if((err64<0), __LINE__, "reading frames failed after %d/%d frames", (int)gotframes, (int)framesize); gotframes+=err64; } while(err64>0 && gotframes<framesize); diff=data_diff(__LINE__, FLOAT32, orgambidata, resultambidata, framesize*ambichannels, eps); fail_if((diff>eps), __LINE__, "ambidata diff %f > %f", diff, eps); diff=data_diff(__LINE__, FLOAT32, orgotherdata, resultotherdata, framesize*extrachannels, eps); fail_if((diff>eps), __LINE__, "otherdata diff %f > %f", diff, eps); fail_if((AMBIX_ERR_SUCCESS!=ambix_close(ambix)), __LINE__, "closing ambix file %p", ambix); ambix=NULL; free(resultambidata); free(ambidata); free(resultotherdata); free(otherdata); free(orgambidata); free(orgotherdata); ambix_matrix_deinit(&eye); ambixtest_rmfile(path); }
void datamul_4_2_tests(uint32_t chunksize, float32_t eps) { uint32_t r, c, rows, cols; float32_t errf; uint64_t frames=8; uint32_t rawchannels=2; uint32_t cokchannels=4; float32_t*inputdata; float32_t*outputdata; float32_t*targetdata; float32_t freq=500; ambix_matrix_t eye = {0, 0, NULL}; STARTTEST(""); inputdata =data_sine(frames, rawchannels, freq); targetdata=data_sine(frames, cokchannels, freq); outputdata=(float32_t*)malloc(sizeof(float32_t)*frames*cokchannels); fail_if((NULL==outputdata), __LINE__, "couldn't allocate outputdata"); ambix_matrix_init(cokchannels, rawchannels, &eye); rows=eye.rows; cols=eye.cols; for(r=0; r<rows; r++) { for(c=0; c<cols; c++) { eye.data[r][c]=(1+r+c)%2; } } #if 0 matrix_print(&eye); printf("input\n"); data_print(inputdata, rawchannels*frames); #endif fail_if(AMBIX_ERR_SUCCESS!=ambix_matrix_multiply_float32(outputdata, &eye, inputdata, frames), __LINE__, "data multilplication failed"); #if 0 printf("output\n"); data_print(outputdata, cokchannels*frames); printf("target\n"); data_print(targetdata, cokchannels*frames); #endif errf=data_diff(__LINE__, targetdata, outputdata, frames*cokchannels, eps); fail_if(!(errf<eps), __LINE__, "diffing data multiplication returned %f (>%f)", errf, eps); #if 0 printf("matrix:\n"); matrix_print(&eye); printf("input :\n"); data_print(inputdata, frames*channels); printf("output:\n"); data_print(outputdata,frames*channels); #endif ambix_matrix_deinit(&eye); free(inputdata); free(outputdata); free(targetdata); }
void mtx_diff(float32_t eps) { float32_t errf; ambix_matrix_t *left=NULL, *right=NULL; unsigned int i; const unsigned int rows=4; const unsigned int cols=3; float32_t*leftdata=leftdata_4_3; float32_t*rightdata=malloc(sizeof(leftdata_4_3)); float32_t maxeps=eps; STARTTEST("\n"); left=ambix_matrix_create(); right=ambix_matrix_create(); /* comparisons: - failing tests: - different dimensions - left/right matrix is NULL - non-failing tests: - all values diff==0 - all values diff<eps - few values diff<eps - many values diff<eps */ fail_if((left !=ambix_matrix_init(3, 4, left )), __LINE__, "initializing left matrix failed"); fail_if((right!=ambix_matrix_init(3, 4, right)), __LINE__, "initializing right matrix failed"); /* compare equal matrices */ STARTTEST("ident\n"); ambix_matrix_fill_data(left, leftdata); errf=matrix_diff(__LINE__, left, left, eps); fail_if(errf>0.f, __LINE__, "diffing mtx with itself returned %g (>%g)", errf, 0.f); /* compare equal matrices */ STARTTEST("equal\n"); for(i=0; i<rows*cols; i++) { rightdata[i]=leftdata[i]; } ambix_matrix_fill_data(left , leftdata); ambix_matrix_fill_data(right, rightdata); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf>0.f, __LINE__, "diffing mtx with copy returned %g (>%g)", errf, 0.f); /* compare matrices where all values differ, but <eps */ STARTTEST("all<eps\n"); for(i=0; i<rows*cols; i++) { rightdata[i]=leftdata[i]+eps*0.5; } ambix_matrix_fill_data(left , leftdata); ambix_matrix_fill_data(right, rightdata); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf>eps, __LINE__, "diffing mtx with mtx+eps/2 returned %g (>%g)", errf, eps); for(i=0; i<rows*cols; i++) { rightdata[i]=leftdata[i]-eps*0.5; } ambix_matrix_fill_data(left , leftdata); ambix_matrix_fill_data(right, rightdata); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf>eps, __LINE__, "diffing mtx with mtx-eps/2 returned %g (>%g)", errf, eps); /* compare matrices where many values differ with <eps; but one with >eps */ STARTTEST("most<eps;one>eps\n"); for(i=0; i<rows*cols; i++) { rightdata[i]=leftdata[i]; } for(i=0; i<rows; i++) { rightdata[i]=leftdata[i]+eps*0.5; } rightdata[0]=leftdata[0]+eps*1.5; ambix_matrix_fill_data(left , leftdata); ambix_matrix_fill_data(right, rightdata); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf>(eps*2.0), __LINE__, "diffing mtx with one value>eps returned %g (>%g)", errf, eps); fail_if(errf<(eps*1.0), __LINE__, "diffing mtx with one value>eps returned %g (>%g)", errf, eps); /* compare matrices where most values differ with >eps */ STARTTEST("most>eps\n"); for(i=0; i<rows*cols; i++) { rightdata[i]=leftdata[i]; } maxeps=eps*1.5; for(i=0; i<(rows*cols)-1; i++) { rightdata[i]=leftdata[i]-maxeps; } ambix_matrix_fill_data(left , leftdata); ambix_matrix_fill_data(right, rightdata); errf=matrix_diff(__LINE__, left, right, eps); fail_if(errf<eps*1.0, __LINE__, "diffing mtx with one value>eps returned %g (<%g)", errf, eps*1.0); fail_if(errf>eps*2.0, __LINE__, "diffing mtx with one value>eps returned %g (<%g)", errf, eps*2.0); ambix_matrix_destroy(left); ambix_matrix_destroy(right); free(rightdata); STOPTEST("\n"); }
void mtxinverse_tests(float32_t eps) { float32_t errf; ambix_matrix_t *mtx=0, *testresult=0; float32_t*transposedata = (float32_t*)calloc(3*4, sizeof(float32_t)); STARTTEST("\n"); /* fill in some test data 4x4 */ STARTTEST("[4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill_data(mtx, leftdata_4_4); testresult=ambix_matrix_init(4, 4, testresult); ambix_matrix_fill_data(testresult, resultpinv_4_4); mtxinverse_test(mtx, testresult, eps); /* fill in some test data 4x3 */ STARTTEST("[4x3]\n"); mtx=ambix_matrix_init(4, 3, mtx); ambix_matrix_fill_data(mtx, leftdata_4_3); testresult=ambix_matrix_init(3, 4, testresult); ambix_matrix_fill_data(testresult, resultpinv_4_3); mtxinverse_test(mtx, testresult, eps); /* fill in some test data 3x4 */ STARTTEST("[3x4]\n"); data_transpose(transposedata, leftdata_4_3, 4, 3); mtx=ambix_matrix_init(3, 4, mtx); ambix_matrix_fill_data(mtx, transposedata); data_transpose(transposedata, resultpinv_4_3, 3, 4); testresult=ambix_matrix_init(4, 3, testresult); ambix_matrix_fill_data(testresult, transposedata); mtxinverse_test(mtx, testresult, eps); /* fill in some test data 4x4 */ STARTTEST("[identity:4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill(mtx, AMBIX_MATRIX_IDENTITY); testresult=ambix_matrix_init(4, 4, testresult); ambix_matrix_fill(testresult, AMBIX_MATRIX_IDENTITY); mtxinverse_test(mtx, testresult, eps); STARTTEST("[one:4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill(mtx, AMBIX_MATRIX_ONE); mtxinverse_test(mtx, NULL, eps); STARTTEST("[zero:4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill(mtx, AMBIX_MATRIX_ZERO); mtxinverse_test(mtx, NULL, eps); STARTTEST("[SID:4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill(mtx, AMBIX_MATRIX_SID); testresult=ambix_matrix_init(4, 4, testresult); ambix_matrix_fill(testresult, AMBIX_MATRIX_TO_SID); mtxinverse_test(mtx, testresult, eps); STARTTEST("[N3D:4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill(mtx, AMBIX_MATRIX_N3D); testresult=ambix_matrix_init(4, 4, testresult); ambix_matrix_fill(testresult, AMBIX_MATRIX_TO_N3D); mtxinverse_test(mtx, testresult, eps); STARTTEST("[FUMA:4x4]\n"); mtx=ambix_matrix_init(4, 4, mtx); ambix_matrix_fill(mtx, AMBIX_MATRIX_FUMA); testresult=ambix_matrix_init(4, 4, testresult); ambix_matrix_fill(testresult, AMBIX_MATRIX_TO_FUMA); mtxinverse_test(mtx, testresult, eps); ambix_matrix_destroy(mtx); ambix_matrix_destroy(testresult); free(transposedata); STOPTEST("\n"); }