OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86MAC64.git] / util / X86MAC64 / include / gsl / gsl_spmatrix_complex_double.h
1 /* spmatrix/gsl_spmatrix_double.h
2  * 
3  * Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Patrick Alken
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or (at
8  * your option) any later version.
9  * 
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  * 
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19
20 #ifndef __GSL_SPMATRIX_COMPLEX_DOUBLE_H__
21 #define __GSL_SPMATRIX_COMPLEX_DOUBLE_H__
22
23 #include <stdlib.h>
24 #include <gsl/gsl_math.h>
25 #include <gsl/gsl_bst.h>
26 #include <gsl/gsl_vector_complex_double.h>
27 #include <gsl/gsl_matrix_complex_double.h>
28
29 #undef __BEGIN_DECLS
30 #undef __END_DECLS
31 #ifdef __cplusplus
32 # define __BEGIN_DECLS extern "C" {
33 # define __END_DECLS }
34 #else
35 # define __BEGIN_DECLS /* empty */
36 # define __END_DECLS /* empty */
37 #endif
38
39 __BEGIN_DECLS
40
41 /*
42  * COO format:
43  *
44  * If data[n] = A_{ij}, then:
45  *   i = A->i[n]
46  *   j = A->p[n]
47  *
48  * Compressed column format (CSC):
49  *
50  * If data[n] = A_{ij}, then:
51  *   i = A->i[n]
52  *   A->p[j] <= n < A->p[j+1]
53  * so that column j is stored in
54  * [ data[p[j]], data[p[j] + 1], ..., data[p[j+1] - 1] ]
55  *
56  * Compressed row format (CSR):
57  *
58  * If data[n] = A_{ij}, then:
59  *   j = A->i[n]
60  *   A->p[i] <= n < A->p[i+1]
61  * so that row i is stored in
62  * [ data[p[i]], data[p[i] + 1], ..., data[p[i+1] - 1] ]
63  */
64
65 typedef struct
66 {
67   size_t size1;              /* number of rows */
68   size_t size2;              /* number of columns */
69
70   /* i (size nzmax) contains:
71    *
72    * COO/CSC: row indices
73    * CSR: column indices
74    */
75   int *i;
76
77   double *data;               /* matrix elements of size nzmax */
78
79   /*
80    * COO: p[n] = column number of element data[n]
81    * CSC: p[j] = index in data of first non-zero element in column j
82    * CSR: p[i] = index in data of first non-zero element in row i
83    */
84   int *p;
85
86   size_t nzmax;              /* maximum number of matrix elements */
87   size_t nz;                 /* number of non-zero values in matrix */
88
89   gsl_bst_workspace *tree;   /* binary tree structure */
90   gsl_spmatrix_pool *pool;   /* memory pool for binary tree nodes */
91   size_t node_size;          /* size of individual tree node in bytes */
92
93   /*
94    * workspace of size 2*MAX(size1,size2)*MAX(sizeof(double),sizeof(int))
95    * used in various routines
96    */
97   union
98     {
99       void *work_void;
100       int *work_int;
101       double *work_atomic;
102     } work;
103
104   int sptype;                /* sparse storage type */
105   size_t spflags;            /* GSL_SPMATRIX_FLG_xxx */
106 } gsl_spmatrix_complex;
107
108 /*
109  * Prototypes
110  */
111
112 /* allocation / initialization */
113
114 gsl_spmatrix_complex * gsl_spmatrix_complex_alloc (const size_t n1, const size_t n2);
115 gsl_spmatrix_complex * gsl_spmatrix_complex_alloc_nzmax (const size_t n1, const size_t n2,
116                                                                      const size_t nzmax, const int sptype);
117 void gsl_spmatrix_complex_free (gsl_spmatrix_complex * m);
118 int gsl_spmatrix_complex_realloc (const size_t nzmax, gsl_spmatrix_complex * m);
119 size_t gsl_spmatrix_complex_nnz (const gsl_spmatrix_complex * m);
120 const char * gsl_spmatrix_complex_type (const gsl_spmatrix_complex * m);
121 int gsl_spmatrix_complex_set_zero (gsl_spmatrix_complex * m);
122 int gsl_spmatrix_complex_tree_rebuild (gsl_spmatrix_complex * m);
123
124 /* compress */
125
126 int gsl_spmatrix_complex_csc (gsl_spmatrix_complex * dest, const gsl_spmatrix_complex * src);
127 int gsl_spmatrix_complex_csr (gsl_spmatrix_complex * dest, const gsl_spmatrix_complex * src);
128 gsl_spmatrix_complex * gsl_spmatrix_complex_compress (const gsl_spmatrix_complex * src, const int sptype);
129 gsl_spmatrix_complex * gsl_spmatrix_complex_compcol (const gsl_spmatrix_complex * src);
130 gsl_spmatrix_complex * gsl_spmatrix_complex_ccs (const gsl_spmatrix_complex * src);
131 gsl_spmatrix_complex * gsl_spmatrix_complex_crs (const gsl_spmatrix_complex * src);
132
133 /* copy */
134
135 int gsl_spmatrix_complex_memcpy (gsl_spmatrix_complex * dest, const gsl_spmatrix_complex * src);
136
137 /* file I/O */
138
139 int gsl_spmatrix_complex_fprintf (FILE * stream, const gsl_spmatrix_complex * m, const char * format);
140 gsl_spmatrix_complex * gsl_spmatrix_complex_fscanf (FILE * stream);
141 int gsl_spmatrix_complex_fwrite (FILE * stream, const gsl_spmatrix_complex * m);
142 int gsl_spmatrix_complex_fread (FILE * stream, gsl_spmatrix_complex * m);
143
144 /* get/set */
145
146 gsl_complex gsl_spmatrix_complex_get (const gsl_spmatrix_complex * m, const size_t i, const size_t j);
147 int gsl_spmatrix_complex_set (gsl_spmatrix_complex * m, const size_t i, const size_t j, const gsl_complex x);
148 gsl_complex * gsl_spmatrix_complex_ptr (const gsl_spmatrix_complex * m, const size_t i, const size_t j);
149
150 /* operations */
151
152 int gsl_spmatrix_complex_scale (gsl_spmatrix_complex * m, const gsl_complex x);
153 int gsl_spmatrix_complex_scale_columns (gsl_spmatrix_complex * m, const gsl_vector_complex * x);
154 int gsl_spmatrix_complex_scale_rows (gsl_spmatrix_complex * m, const gsl_vector_complex * x);
155 int gsl_spmatrix_complex_add (gsl_spmatrix_complex * c, const gsl_spmatrix_complex * a, const gsl_spmatrix_complex * b);
156 int gsl_spmatrix_complex_dense_add (gsl_matrix_complex * a, const gsl_spmatrix_complex * b);
157 int gsl_spmatrix_complex_dense_sub (gsl_matrix_complex * a, const gsl_spmatrix_complex * b);
158 int gsl_spmatrix_complex_d2sp (gsl_spmatrix_complex * T, const gsl_matrix_complex * A);
159 int gsl_spmatrix_complex_sp2d (gsl_matrix_complex * A, const gsl_spmatrix_complex * S);
160
161 #ifndef GSL_DISABLE_DEPRECATED
162
163 int gsl_spmatrix_complex_add_to_dense (gsl_matrix_complex * a, const gsl_spmatrix_complex * b);
164
165 #endif
166
167 /* properties */
168
169 int gsl_spmatrix_complex_equal (const gsl_spmatrix_complex * a, const gsl_spmatrix_complex * b);
170
171 /* swap */
172
173 int gsl_spmatrix_complex_transpose (gsl_spmatrix_complex * m);
174 int gsl_spmatrix_complex_transpose2 (gsl_spmatrix_complex * m);
175 int gsl_spmatrix_complex_transpose_memcpy (gsl_spmatrix_complex * dest, const gsl_spmatrix_complex * src);
176
177 __END_DECLS
178
179 #endif /* __GSL_SPMATRIX_COMPLEX_DOUBLE_H__ */