Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:03:54

0001 /* spmatrix/gsl_spmatrix_long_double.h
0002  * 
0003  * Copyright (C) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Patrick Alken
0004  * 
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 3 of the License, or (at
0008  * your option) any later version.
0009  * 
0010  * This program is distributed in the hope that it will be useful, but
0011  * WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * General Public License for more details.
0014  * 
0015  * You should have received a copy of the GNU General Public License
0016  * along with this program; if not, write to the Free Software
0017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef __GSL_SPMATRIX_COMPLEX_LONG_DOUBLE_H__
0021 #define __GSL_SPMATRIX_COMPLEX_LONG_DOUBLE_H__
0022 
0023 #include <stdlib.h>
0024 #include <gsl/gsl_math.h>
0025 #include <gsl/gsl_bst.h>
0026 #include <gsl/gsl_vector_complex_long_double.h>
0027 #include <gsl/gsl_matrix_complex_long_double.h>
0028 
0029 #undef __BEGIN_DECLS
0030 #undef __END_DECLS
0031 #ifdef __cplusplus
0032 # define __BEGIN_DECLS extern "C" {
0033 # define __END_DECLS }
0034 #else
0035 # define __BEGIN_DECLS /* empty */
0036 # define __END_DECLS /* empty */
0037 #endif
0038 
0039 __BEGIN_DECLS
0040 
0041 /*
0042  * COO format:
0043  *
0044  * If data[n] = A_{ij}, then:
0045  *   i = A->i[n]
0046  *   j = A->p[n]
0047  *
0048  * Compressed column format (CSC):
0049  *
0050  * If data[n] = A_{ij}, then:
0051  *   i = A->i[n]
0052  *   A->p[j] <= n < A->p[j+1]
0053  * so that column j is stored in
0054  * [ data[p[j]], data[p[j] + 1], ..., data[p[j+1] - 1] ]
0055  *
0056  * Compressed row format (CSR):
0057  *
0058  * If data[n] = A_{ij}, then:
0059  *   j = A->i[n]
0060  *   A->p[i] <= n < A->p[i+1]
0061  * so that row i is stored in
0062  * [ data[p[i]], data[p[i] + 1], ..., data[p[i+1] - 1] ]
0063  */
0064 
0065 typedef struct
0066 {
0067   size_t size1;              /* number of rows */
0068   size_t size2;              /* number of columns */
0069 
0070   /* i (size nzmax) contains:
0071    *
0072    * COO/CSC: row indices
0073    * CSR: column indices
0074    */
0075   int *i;
0076 
0077   long double *data;               /* matrix elements of size nzmax */
0078 
0079   /*
0080    * COO: p[n] = column number of element data[n]
0081    * CSC: p[j] = index in data of first non-zero element in column j
0082    * CSR: p[i] = index in data of first non-zero element in row i
0083    */
0084   int *p;
0085 
0086   size_t nzmax;              /* maximum number of matrix elements */
0087   size_t nz;                 /* number of non-zero values in matrix */
0088 
0089   gsl_bst_workspace *tree;   /* binary tree structure */
0090   gsl_spmatrix_pool *pool;   /* memory pool for binary tree nodes */
0091   size_t node_size;          /* size of individual tree node in bytes */
0092 
0093   /*
0094    * workspace of size 2*MAX(size1,size2)*MAX(sizeof(long double),sizeof(int))
0095    * used in various routines
0096    */
0097   union
0098     {
0099       void *work_void;
0100       int *work_int;
0101       long double *work_atomic;
0102     } work;
0103 
0104   int sptype;                /* sparse storage type */
0105   size_t spflags;            /* GSL_SPMATRIX_FLG_xxx */
0106 } gsl_spmatrix_complex_long_double;
0107 
0108 /*
0109  * Prototypes
0110  */
0111 
0112 /* allocation / initialization */
0113 
0114 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_alloc (const size_t n1, const size_t n2);
0115 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_alloc_nzmax (const size_t n1, const size_t n2,
0116                                                                      const size_t nzmax, const int sptype);
0117 void gsl_spmatrix_complex_long_double_free (gsl_spmatrix_complex_long_double * m);
0118 int gsl_spmatrix_complex_long_double_realloc (const size_t nzmax, gsl_spmatrix_complex_long_double * m);
0119 size_t gsl_spmatrix_complex_long_double_nnz (const gsl_spmatrix_complex_long_double * m);
0120 const char * gsl_spmatrix_complex_long_double_type (const gsl_spmatrix_complex_long_double * m);
0121 int gsl_spmatrix_complex_long_double_set_zero (gsl_spmatrix_complex_long_double * m);
0122 int gsl_spmatrix_complex_long_double_tree_rebuild (gsl_spmatrix_complex_long_double * m);
0123 
0124 /* compress */
0125 
0126 int gsl_spmatrix_complex_long_double_csc (gsl_spmatrix_complex_long_double * dest, const gsl_spmatrix_complex_long_double * src);
0127 int gsl_spmatrix_complex_long_double_csr (gsl_spmatrix_complex_long_double * dest, const gsl_spmatrix_complex_long_double * src);
0128 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_compress (const gsl_spmatrix_complex_long_double * src, const int sptype);
0129 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_compcol (const gsl_spmatrix_complex_long_double * src);
0130 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_ccs (const gsl_spmatrix_complex_long_double * src);
0131 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_crs (const gsl_spmatrix_complex_long_double * src);
0132 
0133 /* copy */
0134 
0135 int gsl_spmatrix_complex_long_double_memcpy (gsl_spmatrix_complex_long_double * dest, const gsl_spmatrix_complex_long_double * src);
0136 
0137 /* file I/O */
0138 
0139 int gsl_spmatrix_complex_long_double_fprintf (FILE * stream, const gsl_spmatrix_complex_long_double * m, const char * format);
0140 gsl_spmatrix_complex_long_double * gsl_spmatrix_complex_long_double_fscanf (FILE * stream);
0141 int gsl_spmatrix_complex_long_double_fwrite (FILE * stream, const gsl_spmatrix_complex_long_double * m);
0142 int gsl_spmatrix_complex_long_double_fread (FILE * stream, gsl_spmatrix_complex_long_double * m);
0143 
0144 /* get/set */
0145 
0146 gsl_complex_long_double gsl_spmatrix_complex_long_double_get (const gsl_spmatrix_complex_long_double * m, const size_t i, const size_t j);
0147 int gsl_spmatrix_complex_long_double_set (gsl_spmatrix_complex_long_double * m, const size_t i, const size_t j, const gsl_complex_long_double x);
0148 gsl_complex_long_double * gsl_spmatrix_complex_long_double_ptr (const gsl_spmatrix_complex_long_double * m, const size_t i, const size_t j);
0149 
0150 /* operations */
0151 
0152 int gsl_spmatrix_complex_long_double_scale (gsl_spmatrix_complex_long_double * m, const gsl_complex_long_double x);
0153 int gsl_spmatrix_complex_long_double_scale_columns (gsl_spmatrix_complex_long_double * m, const gsl_vector_complex_long_double * x);
0154 int gsl_spmatrix_complex_long_double_scale_rows (gsl_spmatrix_complex_long_double * m, const gsl_vector_complex_long_double * x);
0155 int gsl_spmatrix_complex_long_double_add (gsl_spmatrix_complex_long_double * c, const gsl_spmatrix_complex_long_double * a, const gsl_spmatrix_complex_long_double * b);
0156 int gsl_spmatrix_complex_long_double_dense_add (gsl_matrix_complex_long_double * a, const gsl_spmatrix_complex_long_double * b);
0157 int gsl_spmatrix_complex_long_double_dense_sub (gsl_matrix_complex_long_double * a, const gsl_spmatrix_complex_long_double * b);
0158 int gsl_spmatrix_complex_long_double_d2sp (gsl_spmatrix_complex_long_double * T, const gsl_matrix_complex_long_double * A);
0159 int gsl_spmatrix_complex_long_double_sp2d (gsl_matrix_complex_long_double * A, const gsl_spmatrix_complex_long_double * S);
0160 
0161 #ifndef GSL_DISABLE_DEPRECATED
0162 
0163 int gsl_spmatrix_complex_long_double_add_to_dense (gsl_matrix_complex_long_double * a, const gsl_spmatrix_complex_long_double * b);
0164 
0165 #endif
0166 
0167 /* properties */
0168 
0169 int gsl_spmatrix_complex_long_double_equal (const gsl_spmatrix_complex_long_double * a, const gsl_spmatrix_complex_long_double * b);
0170 
0171 /* swap */
0172 
0173 int gsl_spmatrix_complex_long_double_transpose (gsl_spmatrix_complex_long_double * m);
0174 int gsl_spmatrix_complex_long_double_transpose2 (gsl_spmatrix_complex_long_double * m);
0175 int gsl_spmatrix_complex_long_double_transpose_memcpy (gsl_spmatrix_complex_long_double * dest, const gsl_spmatrix_complex_long_double * src);
0176 
0177 __END_DECLS
0178 
0179 #endif /* __GSL_SPMATRIX_COMPLEX_LONG_DOUBLE_H__ */