File: test_determinant.c

package info (click to toggle)
sphinxbase 0.8%2B5prealpha-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,592 kB
  • ctags: 3,296
  • sloc: ansic: 29,950; sh: 11,802; makefile: 679; python: 335; perl: 121; yacc: 93; lex: 50
file content (36 lines) | stat: -rw-r--r-- 589 bytes parent folder | download | duplicates (6)
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
#include <stdio.h>
#include <string.h>

#include "matrix.h"
#include "ckd_alloc.h"

const float32 foo[3][3] = {
	{2, 0.42, 1},
	{0.42, 2, -0.3},
	{1, -0.3, 2}
};
const float32 bar[3][3] = {
	{1, 0, 1},
	{0, 1, 0},
	{0, 0, 1}
};

int
main(int argc, char *argv[])
{
	float32 **a;

	a = (float32 **)ckd_calloc_2d(3, 3, sizeof(float32));

	memcpy(a[0], foo, sizeof(float32) * 3 * 3);
	/* Should see 5.22 */
	printf("%.2f\n", determinant(a, 3));

	/* Should see -1.0 */
	memcpy(a[0], bar, sizeof(float32) * 3 * 3);
	printf("%.2f\n", determinant(a, 3));

	ckd_free_2d((void **)a);

	return 0;
}