JunkBox_Lib++ (for Windows) 1.10.1
Loading...
Searching...
No Matches
matrix.h
Go to the documentation of this file.
1#ifndef __JBXL_MATRIX_LIBRARY_H_
2#define __JBXL_MATRIX_LIBRARY_H_
3
10#include "common.h"
11#include "mt.h"
12
13#include <math.h>
14#include <float.h>
15
16#ifndef va_start
17 #include <stdarg.h>
18#endif
19
20
21typedef struct _ivector {
22 int x;
23 int y;
24 int z;
25 double n;
26} ivector;
27
28
29typedef struct _vector {
30 double x;
31 double y;
32 double z;
33 double n;
34} vector;
35
36
37typedef struct _quaternion {
38 double s;
39 double x;
40 double y;
41 double z;
42 double n;
44
45
53typedef struct _imatrix {
54 int n;
55 int r;
56 int *sz;
57 int *mx;
58} imatrix;
59
60
68typedef struct _matrix {
69 int n;
70 int r;
71 int *sz;
72 double *mx;
73} matrix;
74
75
76#define in_vector(a, b) ((a).x*(b).x+(a).y*(b).y+(a).z*(b).z)
77#define add_vector(a, b) set_vector((a).x+(b).x,(a).y+(b).y,(a).z+(b).z)
78#define sub_vector(a, b) set_vector((a).x-(b).x,(a).y-(b).y,(a).z-(b).z)
79#define add_ivector(a, b) set_ivector((a).x+(b).x,(a).y+(b).y,(a).z+(b).z)
80#define sub_ivector(a, b) set_ivector((a).x-(b).x,(a).y-(b).y,(a).z-(b).z)
81#define normal_vector(a) (a).r = sqrt((double)((a).x*(a).x)+(a).y*(a).y+(a).z*(a).z);
82
83#define Vt(m, i) ((m).mx[(i)-1])
84#define Mx(m, i, j) ((m).mx[(j)-1+(m).sz[1]*((i)-1)])
85
86#define Mx1(m, i) ((m).mx[(i)-1])
87#define Mx2(m, i, j) ((m).mx[(j)-1+(m).sz[1]*((i)-1)])
88#define Mx3(m, i, j, k) ((m).mx[(k)-1+(m).sz[2]*((j)-1)+(m).sz[1]*(m).sz[2]*((i)-1)])
89#define Mx4(m, i, j, k, l) ((m).mx[(l)-1+(m).sz[3]*((k)-1)+(m).sz[2]*(m).sz[3]*((j)-1) +\
90 (m).sz[1]*(m).sz[2]*(m).sz[3]*((i)-1)])
91
94vector set_vector(double x, double y, double z);
95ivector set_ivector(int x, int y, int z);
97
100
101matrix make_matrix1(int n);
102matrix make_matrix2(int n, int m);
103matrix make_matrix (int n, int* sz);
104
106imatrix make_imatrix2(int n, int m);
107imatrix make_imatrix (int n, int* sz);
108
109
110double* get_matrix(matrix a, ...);
114void copy_matrix(matrix a, matrix b);
115void free_matrix(matrix* a);
117void print_matrix(FILE* fp, matrix a);
118
119int* get_imatrix(imatrix a, ...);
123void copy_imatrix(imatrix a, imatrix b);
124void free_imatrix(imatrix* a);
126void print_imatrix(FILE* fp, imatrix a);
127
128//
133
134
135#endif
汎用共通ヘッダ
void copy_matrix(matrix a, matrix b)
Definition matrix.cpp:523
void copy_imatrix(imatrix a, imatrix b)
Definition matrix.cpp:545
vector unit_vector(vector a)
Definition matrix.cpp:18
void print_imatrix(FILE *fp, imatrix a)
Definition matrix.cpp:843
void free_imatrix(imatrix *a)
Definition matrix.cpp:425
matrix make_matrix1(int n)
Definition matrix.cpp:188
vector unit_ivector(ivector a)
Definition matrix.cpp:49
matrix add_matrix(matrix a, matrix b)
Definition matrix.cpp:567
matrix sub_matrix(matrix a, matrix b)
Definition matrix.cpp:621
matrix make_matrix2(int n, int m)
Definition matrix.cpp:257
ivector f2ivector(vector a)
Definition matrix.cpp:125
ivector set_ivector(int x, int y, int z)
Definition matrix.cpp:104
vector i2vector(ivector a)
Definition matrix.cpp:145
vector ex_vector(vector a, vector b)
Definition matrix.cpp:167
vector set_vector(double x, double y, double z)
Definition matrix.cpp:82
matrix minimum2(matrix a, matrix x)
Definition matrix.cpp:967
double * get_matrix(matrix a,...)
Definition matrix.cpp:449
void clear_matrix(matrix *a)
matrix decompQR(matrix xx, imatrix col)
Definition matrix.cpp:869
imatrix sub_imatrix(imatrix a, imatrix b)
Definition matrix.cpp:648
imatrix add_imatrix(imatrix a, imatrix b)
Definition matrix.cpp:594
void free_matrix(matrix *a)
Definition matrix.cpp:408
int * get_imatrix(imatrix a,...)
Definition matrix.cpp:488
imatrix mlt_imatrix(imatrix a, imatrix b)
Definition matrix.cpp:751
void clear_imatrix(imatrix *a)
imatrix make_imatrix2(int n, int m)
Definition matrix.cpp:294
matrix mlt_matrix(matrix a, matrix b)
Definition matrix.cpp:675
matrix make_matrix(int n, int *sz)
Definition matrix.cpp:331
matrix invrU_matrix(matrix x)
Definition matrix.cpp:1045
imatrix make_imatrix(int n, int *sz)
Definition matrix.cpp:371
matrix trans_matrix(matrix a)
Definition matrix.cpp:1013
void print_matrix(FILE *fp, matrix a)
Definition matrix.cpp:824
imatrix make_imatrix1(int n)
Definition matrix.cpp:222
数学関数ヘッダ mt.h
int * sz
各次元の要素数 sz[0]?sz[n-1]
Definition matrix.h:56
int * mx
要素 mx[0]?mx[r-1]
Definition matrix.h:57
int n
次元数
Definition matrix.h:54
int r
全要素数 sz[0]+sz[1]+...+sz[n-1]
Definition matrix.h:55
int y
y方向成分
Definition matrix.h:23
int z
z方向成分
Definition matrix.h:24
int x
x方向成分
Definition matrix.h:22
double n
ベクトルの大きさ
Definition matrix.h:25
double * mx
要素 mx[0]?mx[r-1]
Definition matrix.h:72
int * sz
各次元の要素数 sz[0]?sz[n-1]
Definition matrix.h:71
int n
次元数
Definition matrix.h:69
int r
全要素数 sz[0]+sz[1]+...+sz[n-1]
Definition matrix.h:70
double z
z成分
Definition matrix.h:41
double y
y成分
Definition matrix.h:40
double n
ベクトルの大きさ
Definition matrix.h:42
double s
s
Definition matrix.h:38
double x
x成分
Definition matrix.h:39
double z
z方向成分
Definition matrix.h:32
double y
y方向成分
Definition matrix.h:31
double n
ベクトルの大きさ
Definition matrix.h:33
double x
x方向成分
Definition matrix.h:30