MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
matrix.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libann/matrix.h,v 1.9 2011/02/23 13:02:29 mattaboni Exp $ */
2 /*
3  * MBDyn (C) is a multibody analysis code.
4  * http://www.mbdyn.org
5  *
6  * Copyright (C) 1996-2008
7  *
8  * Pierangelo Masarati <masarati@aero.polimi.it>
9  * Paolo Mantegazza <mantegazza@aero.polimi.it>
10  *
11  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12  * via La Masa, 34 - 20156 Milano, Italy
13  * http://www.aero.polimi.it
14  *
15  * Changing this copyright notice is forbidden.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation (version 2 of the License).
20  *
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */
31 /*
32  * Copyright (C) 2010
33  *
34  * Mattia Mattaboni <mattaboni@aero.polimi.it>
35  */
36 
37 #ifndef ANN_MATRIX_H
38 #define ANN_MATRIX_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif /* __cplusplus */
43 
44 #include <stdio.h>
45 
46 #define W_M_NONE (0x00U)
47 #define W_M_TEXT (0x01U)
48 #define W_M_BIN (0x02U)
49 #define W_M_BIN_ROW (0x04U)
50 
51 /* codici errore */
52 typedef enum {
53  MAT_OK = 0,
58 } mat_res_t;
59 
60 /* elemento classe matrice */
61 typedef struct matrix {
62  double ** mat;
63  unsigned Nrow;
64  unsigned Ncolumn;
65 } matrix;
66 
67 /* elemento classe vettore */
68 typedef struct vector {
69  double * vec;
70  unsigned dimension;
71 } vector;
72 
73 /* prototipi funzioni */
74 
75 mat_res_t matrix_init( matrix *, unsigned , unsigned );
76 mat_res_t vector_init( vector *, unsigned );
79 
81 mat_res_t matrix_eye( matrix *, double );
82 mat_res_t matrix_copy( matrix *, matrix *, double );
83 mat_res_t vector_copy( vector *, vector *, double );
85 mat_res_t matrix_prod( matrix * , matrix *, matrix *, double );
86 mat_res_t matrix_prod_sym( matrix * , matrix *, matrix *, double );
91 mat_res_t matrix_sum( matrix *, matrix *, matrix *, double );
93 mat_res_t vector_sum( vector *, vector *, vector *, double );
95 mat_res_t scalar_prod( vector *, vector *, double *);
97 
98 mat_res_t matrix_write( matrix *, FILE *, unsigned );
99 mat_res_t vector_write( vector *, FILE *, unsigned );
100 mat_res_t matrix_read( matrix *, FILE *, unsigned );
101 mat_res_t vector_read( vector *, FILE *, unsigned );
102 
103 mat_res_t matrix_random( matrix *, double, double );
104 mat_res_t vector_random( vector *, double, double );
105 
106 mat_res_t sub_matrix_extract( matrix *, matrix *, unsigned, unsigned);
107 mat_res_t sub_matrix_insert( matrix *, matrix *, unsigned, unsigned);
108 
109 double mean_value( matrix *, int );
110 double variance( matrix *, int );
111 double maximum( matrix *, int );
112 double minimum( matrix *, int );
113 double matrix_trace( matrix * );
114 void matrix_error( mat_res_t, const char * );
115 
116 #ifdef __cplusplus
117 }
118 #endif /* __cplusplus */
119 
120 #endif /* ANN_MATRIX_H */
121 
Definition: matrix.h:68
mat_res_t matrix_prod(matrix *, matrix *, matrix *, double)
Definition: matrix.c:187
mat_res_t matrix_prod_transpose(matrix *, matrix *, matrix *, double)
Definition: matrix.c:284
mat_res_t matrix_sum_transpose(matrix *, matrix *, matrix *, double)
Definition: matrix.c:428
unsigned Ncolumn
Definition: matrix.h:64
mat_res_t matrix_null(matrix *)
Definition: matrix.c:107
void matrix_error(mat_res_t, const char *)
Definition: matrix.c:535
mat_res_t vector_null(vector *)
Definition: matrix.c:176
mat_res_t vector_copy(vector *, vector *, double)
Definition: matrix.c:159
double minimum(matrix *, int)
Definition: matrix.c:628
Definition: matrix.h:53
mat_res_t matrix_destroy(matrix *)
Definition: matrix.c:84
mat_res_t vector_random(vector *, double, double)
Definition: matrix.c:570
mat_res_t matrixT_vector_prod(matrix *, vector *, vector *)
Definition: matrix.c:379
mat_res_t matrix_prod_sym(matrix *, matrix *, matrix *, double)
Definition: matrix.c:212
Definition: matrix.h:61
unsigned dimension
Definition: matrix.h:70
double variance(matrix *, int)
Definition: matrix.c:598
mat_res_t matrix_copy(matrix *, matrix *, double)
Definition: matrix.c:140
mat_res_t vector_sum(vector *, vector *, vector *, double)
Definition: matrix.c:447
double mean_value(matrix *, int)
Definition: matrix.c:586
struct vector vector
mat_res_t matrix_transpose(matrix *, matrix *)
Definition: matrix.c:239
mat_res_t vector_read(vector *, FILE *, unsigned)
Definition: matrix.c:522
double matrix_trace(matrix *)
Definition: matrix.c:644
mat_res_t vector_vector_prod(vector *, vector *, matrix *, double)
Definition: matrix.c:333
mat_res_t scalar_prod(vector *, vector *, double *)
Definition: matrix.c:310
unsigned Nrow
Definition: matrix.h:63
mat_res_t vector_write(vector *, FILE *, unsigned)
Definition: matrix.c:487
mat_res_t matrix_init(matrix *, unsigned, unsigned)
Definition: matrix.c:43
mat_res_t matrix_vector_prod(matrix *, vector *, vector *)
Definition: matrix.c:354
double ** mat
Definition: matrix.h:62
mat_res_t sub_matrix_extract(matrix *, matrix *, unsigned, unsigned)
Definition: matrix.c:656
mat_res_t matrix_eye(matrix *, double)
Definition: matrix.c:122
struct matrix matrix
mat_res_t
Definition: matrix.h:52
double * vec
Definition: matrix.h:69
mat_res_t matrix_transpose_prod(matrix *, matrix *, matrix *, double)
Definition: matrix.c:258
mat_res_t matrix_sum(matrix *, matrix *, matrix *, double)
Definition: matrix.c:409
mat_res_t matrix_read(matrix *, FILE *, unsigned)
Definition: matrix.c:506
mat_res_t matrix_random(matrix *, double, double)
Definition: matrix.c:552
mat_res_t sub_matrix_insert(matrix *, matrix *, unsigned, unsigned)
Definition: matrix.c:674
mat_res_t matrix_write(matrix *, FILE *, unsigned)
Definition: matrix.c:467
mat_res_t vector_destroy(vector *)
Definition: matrix.c:97
double maximum(matrix *, int)
Definition: matrix.c:612
mat_res_t vector_init(vector *, unsigned)
Definition: matrix.c:68