From 00fbdfcbe9b1c3cc9f9f0814fe5f60bbf066cbbf Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sat, 17 Mar 2018 08:15:09 -0600 Subject: Added test target, mul test --- Makefile | 3 +++ redist/test_dcl.c | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e130357..9239c39 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,9 @@ calibrate_client : calibrate_client.c ./lib/libsurvive.so redist/os_generic.c $ static_calibrate : calibrate.c redist/os_generic.c $(DRAWFUNCTIONS) $(LIBSURVIVE_C) tcc -o $@ $^ $(CFLAGS) $(LDFLAGS) -DTCC +test_dcl: ./redist/test_dcl.c ./redist/dclhelpers.c + $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) -DFLT=double -fsanitize=address -fsanitize=undefined + test_minimal_cv: ./src/epnp/test_minimal_cv.c ./lib/libsurvive.so $(CC) -o $@ $^ $(LDFLAGS) $(CFLAGS) diff --git a/redist/test_dcl.c b/redist/test_dcl.c index adea7b5..a9512f8 100644 --- a/redist/test_dcl.c +++ b/redist/test_dcl.c @@ -1,8 +1,8 @@ #include "dclhelpers.h" +#include #include #include - int main() { FLT A[2][4] = { { 0, 1, 2, 3 }, { 4, 5, 6, 7} }; @@ -31,9 +31,25 @@ int main() printf( "The following should be an identity matrix\n" ); dclPrint( MM[0], 3, 3, 3 ); -//void dclTransp( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int n, int m ); + { + FLT A[3][4]; + dclIdentity(A[0], 4, 3); + dclPrint(A[0], 4, 3, 4); + + FLT x[4] = {7, 8, 9, 10}; + FLT R[4]; + + dclMul(R, 1, A[0], 4, x, 1, 4, 1, 3); + dclPrint(x, 1, 4, 1); + dclPrint(R, 1, 4, 1); + + for (int i = 0; i < 3; i++) + assert(R[i] == x[i]); + assert(R[3] == 0.); + } + // void dclTransp( DCL_FLOAT * R, int Rc, const DCL_FLOAT * A, int Ac, int n, int m ); -// dclIdentity( A[0], MATx, 5 ); -// dclPrint( A[0], MATx, MATx, MATy ); + // dclIdentity( A[0], MATx, 5 ); + // dclPrint( A[0], MATx, MATx, MATy ); } -- cgit v1.2.3