1 /* spmatrix/gsl_spmatrix_long_double.h
3 * Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Patrick Alken
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.
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.
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.
20 #ifndef __GSL_SPMATRIX_LONG_DOUBLE_H__
21 #define __GSL_SPMATRIX_LONG_DOUBLE_H__
24 #include <gsl/gsl_math.h>
25 #include <gsl/gsl_bst.h>
26 #include <gsl/gsl_vector_long_double.h>
27 #include <gsl/gsl_matrix_long_double.h>
32 # define __BEGIN_DECLS extern "C" {
33 # define __END_DECLS }
35 # define __BEGIN_DECLS /* empty */
36 # define __END_DECLS /* empty */
44 * If data[n] = A_{ij}, then:
48 * Compressed column format (CSC):
50 * If data[n] = A_{ij}, then:
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] ]
56 * Compressed row format (CSR):
58 * If data[n] = A_{ij}, then:
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] ]
67 size_t size1; /* number of rows */
68 size_t size2; /* number of columns */
70 /* i (size nzmax) contains:
72 * COO/CSC: row indices
77 long double *data; /* matrix elements of size nzmax */
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
86 size_t nzmax; /* maximum number of matrix elements */
87 size_t nz; /* number of non-zero values in matrix */
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 */
94 * workspace of size MAX(size1,size2)*MAX(sizeof(long double),sizeof(int))
95 * used in various routines
101 long double *work_atomic;
104 int sptype; /* sparse storage type */
105 size_t spflags; /* GSL_SPMATRIX_FLG_xxx */
106 } gsl_spmatrix_long_double;
112 /* allocation / initialization */
114 gsl_spmatrix_long_double * gsl_spmatrix_long_double_alloc (const size_t n1, const size_t n2);
115 gsl_spmatrix_long_double * gsl_spmatrix_long_double_alloc_nzmax (const size_t n1, const size_t n2,
116 const size_t nzmax, const int sptype);
117 void gsl_spmatrix_long_double_free (gsl_spmatrix_long_double * m);
118 int gsl_spmatrix_long_double_realloc (const size_t nzmax, gsl_spmatrix_long_double * m);
119 size_t gsl_spmatrix_long_double_nnz (const gsl_spmatrix_long_double * m);
120 const char * gsl_spmatrix_long_double_type (const gsl_spmatrix_long_double * m);
121 int gsl_spmatrix_long_double_set_zero (gsl_spmatrix_long_double * m);
122 int gsl_spmatrix_long_double_tree_rebuild (gsl_spmatrix_long_double * m);
126 int gsl_spmatrix_long_double_csc (gsl_spmatrix_long_double * dest, const gsl_spmatrix_long_double * src);
127 int gsl_spmatrix_long_double_csr (gsl_spmatrix_long_double * dest, const gsl_spmatrix_long_double * src);
128 gsl_spmatrix_long_double * gsl_spmatrix_long_double_compress (const gsl_spmatrix_long_double * src, const int sptype);
129 gsl_spmatrix_long_double * gsl_spmatrix_long_double_compcol (const gsl_spmatrix_long_double * src);
130 gsl_spmatrix_long_double * gsl_spmatrix_long_double_ccs (const gsl_spmatrix_long_double * src);
131 gsl_spmatrix_long_double * gsl_spmatrix_long_double_crs (const gsl_spmatrix_long_double * src);
135 int gsl_spmatrix_long_double_memcpy (gsl_spmatrix_long_double * dest, const gsl_spmatrix_long_double * src);
139 int gsl_spmatrix_long_double_fprintf (FILE * stream, const gsl_spmatrix_long_double * m, const char * format);
140 gsl_spmatrix_long_double * gsl_spmatrix_long_double_fscanf (FILE * stream);
141 int gsl_spmatrix_long_double_fwrite (FILE * stream, const gsl_spmatrix_long_double * m);
142 int gsl_spmatrix_long_double_fread (FILE * stream, gsl_spmatrix_long_double * m);
146 long double gsl_spmatrix_long_double_get (const gsl_spmatrix_long_double * m, const size_t i, const size_t j);
147 int gsl_spmatrix_long_double_set (gsl_spmatrix_long_double * m, const size_t i, const size_t j, const long double x);
148 long double * gsl_spmatrix_long_double_ptr (const gsl_spmatrix_long_double * m, const size_t i, const size_t j);
152 int gsl_spmatrix_long_double_minmax (const gsl_spmatrix_long_double * m, long double * min_out, long double * max_out);
153 int gsl_spmatrix_long_double_min_index (const gsl_spmatrix_long_double * m, size_t * imin_out, size_t * jmin_out);
157 int gsl_spmatrix_long_double_scale (gsl_spmatrix_long_double * m, const long double x);
158 int gsl_spmatrix_long_double_scale_columns (gsl_spmatrix_long_double * m, const gsl_vector_long_double * x);
159 int gsl_spmatrix_long_double_scale_rows (gsl_spmatrix_long_double * m, const gsl_vector_long_double * x);
160 int gsl_spmatrix_long_double_add (gsl_spmatrix_long_double * c, const gsl_spmatrix_long_double * a, const gsl_spmatrix_long_double * b);
161 int gsl_spmatrix_long_double_dense_add (gsl_matrix_long_double * a, const gsl_spmatrix_long_double * b);
162 int gsl_spmatrix_long_double_dense_sub (gsl_matrix_long_double * a, const gsl_spmatrix_long_double * b);
163 int gsl_spmatrix_long_double_d2sp (gsl_spmatrix_long_double * T, const gsl_matrix_long_double * A);
164 int gsl_spmatrix_long_double_sp2d (gsl_matrix_long_double * A, const gsl_spmatrix_long_double * S);
166 #ifndef GSL_DISABLE_DEPRECATED
168 int gsl_spmatrix_long_double_add_to_dense (gsl_matrix_long_double * a, const gsl_spmatrix_long_double * b);
174 int gsl_spmatrix_long_double_equal (const gsl_spmatrix_long_double * a, const gsl_spmatrix_long_double * b);
175 long double gsl_spmatrix_long_double_norm1 (const gsl_spmatrix_long_double * a);
179 int gsl_spmatrix_long_double_transpose (gsl_spmatrix_long_double * m);
180 int gsl_spmatrix_long_double_transpose2 (gsl_spmatrix_long_double * m);
181 int gsl_spmatrix_long_double_transpose_memcpy (gsl_spmatrix_long_double * dest, const gsl_spmatrix_long_double * src);
185 #endif /* __GSL_SPMATRIX_LONG_DOUBLE_H__ */