aboutsummaryrefslogtreecommitdiff
path: root/redist/test_dcl.c
blob: a9512f88743cad76a76e6e2eca617ca13a993655 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "dclhelpers.h"
#include <assert.h>
#include <stdint.h>
#include <stdio.h>

int main()
{
	FLT A[2][4]	= { { 0, 1, 2, 3 }, { 4, 5, 6, 7} };
	FLT B[4][2];
	dclPrint( A[0], 4, 2, 4 );
	dclTransp( B[0], 2, A[0], 4, 2, 4 );
	dclPrint( B[0], 2, 4, 2 );

	int i;
	for( i = 0; i < 8; i++ )
	{
		printf( "%f\n", ((float*)(B[0]))[i] );
	}

	FLT M[3][3] = {
		{ .32, 1, 0 },
		{ 0, 1, 2 },
		{ 1, 0, 1 } };
	FLT Mo[3][3];
	dclInv( Mo[0], 3, M[0], 3, 3 );
	dclPrint( Mo[0], 3, 3, 3 );

	FLT MM[3][3];
	dclMul( MM[0], 3, M[0], 3, Mo[0], 3, 3, 3, 3 );

	printf( "The following should be an identity matrix\n" );
	dclPrint( MM[0], 3, 3, 3 );

	{
		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 );
}