-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix.h
76 lines (53 loc) · 2.3 KB
/
matrix.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* ----------------------------- MNI Header -----------------------------------
@NAME : matrix.h
@INPUT :
@OUTPUT : (nothing)
@RETURNS :
@DESCRIPTION: Header file for general purpose matrix functions
@CREATED : Sept 11, 1997 (J. Taylor)
@MODIFIED :
---------------------------------------------------------------------------- */
#ifndef MATRIX_H
#define MATRIX_H
#define COMPILING_MATRIX
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#ifndef lint
static char matrix_h_rcsid[] = "$Header: /private-cvsroot/statistics/glim_image/matrix.h,v 1.2 2005-04-07 07:38:21 rotor Exp $ MINC (MNI)";
#endif
#ifndef INVALID_DATA
#define INVALID_DATA (-DBL_MAX)
#endif
typedef struct {
int num_rows;
int num_columns;
double **values;
} Matrix;
typedef enum {MATRIX_NEITHER, MATRIX_LEFT, MATRIX_RIGHT, MATRIX_BOTH} Trans_Code;
Matrix *create_matrix(int num_rows, int num_columns);
void delete_matrix(Matrix *matrix);
void multiply_matrix (Matrix *matrix_result, Matrix *matrix_left,
Matrix *matrix_right, Trans_Code transpose);
void multiply_matrix_sym(Matrix *matrix_result, Matrix *matrix_left,
Matrix *matrix_right , Trans_Code transpose);
void multiply_diagonal_left (Matrix *matrix_result, Matrix *matrix_left,
Matrix *matrix_right , Trans_Code transpose);
void multiply_diagonal_right (Matrix *matrix_result, Matrix *matrix_left,
Matrix *matrix_right , Trans_Code transpose);
int invert_matrix_sym (Matrix *matrix_result, Matrix *matrix);
void transpose_matrix (Matrix *matrix_result, Matrix *matrix);
void copy_matrix (Matrix*matrix_result, Matrix *matrix, int num_rows,
int num_columns, double scalar , Trans_Code transpose);
void add_matrix (Matrix *matrix_result, Matrix *matrix_a, Matrix *matrix_b , Trans_Code transpose);
void sub_matrix (Matrix *matrix_result, Matrix *matrix_pos,
Matrix *matrix_neg , Trans_Code transpose);
int print_matrix(FILE *strm, Matrix *matrix);
void sprint_matrix(char **str, Matrix *matrix);
double normalize_vector(Matrix *vector);
double determinant(Matrix *matrix);
void svd_matrix(Matrix **singval, Matrix **buffer,
Matrix *matrix, int free_all);
#endif