File indexing completed on 2025-02-21 10:03:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef __GSL_MATRIX_CHAR_H__
0021 #define __GSL_MATRIX_CHAR_H__
0022
0023 #include <stdlib.h>
0024 #include <gsl/gsl_types.h>
0025 #include <gsl/gsl_errno.h>
0026 #include <gsl/gsl_inline.h>
0027 #include <gsl/gsl_check_range.h>
0028 #include <gsl/gsl_vector_char.h>
0029 #include <gsl/gsl_blas_types.h>
0030
0031 #undef __BEGIN_DECLS
0032 #undef __END_DECLS
0033 #ifdef __cplusplus
0034 # define __BEGIN_DECLS extern "C" {
0035 # define __END_DECLS }
0036 #else
0037 # define __BEGIN_DECLS
0038 # define __END_DECLS
0039 #endif
0040
0041 __BEGIN_DECLS
0042
0043 typedef struct
0044 {
0045 size_t size1;
0046 size_t size2;
0047 size_t tda;
0048 char * data;
0049 gsl_block_char * block;
0050 int owner;
0051 } gsl_matrix_char;
0052
0053 typedef struct
0054 {
0055 gsl_matrix_char matrix;
0056 } _gsl_matrix_char_view;
0057
0058 typedef _gsl_matrix_char_view gsl_matrix_char_view;
0059
0060 typedef struct
0061 {
0062 gsl_matrix_char matrix;
0063 } _gsl_matrix_char_const_view;
0064
0065 typedef const _gsl_matrix_char_const_view gsl_matrix_char_const_view;
0066
0067
0068
0069 gsl_matrix_char *
0070 gsl_matrix_char_alloc (const size_t n1, const size_t n2);
0071
0072 gsl_matrix_char *
0073 gsl_matrix_char_calloc (const size_t n1, const size_t n2);
0074
0075 gsl_matrix_char *
0076 gsl_matrix_char_alloc_from_block (gsl_block_char * b,
0077 const size_t offset,
0078 const size_t n1,
0079 const size_t n2,
0080 const size_t d2);
0081
0082 gsl_matrix_char *
0083 gsl_matrix_char_alloc_from_matrix (gsl_matrix_char * m,
0084 const size_t k1,
0085 const size_t k2,
0086 const size_t n1,
0087 const size_t n2);
0088
0089 gsl_vector_char *
0090 gsl_vector_char_alloc_row_from_matrix (gsl_matrix_char * m,
0091 const size_t i);
0092
0093 gsl_vector_char *
0094 gsl_vector_char_alloc_col_from_matrix (gsl_matrix_char * m,
0095 const size_t j);
0096
0097 void gsl_matrix_char_free (gsl_matrix_char * m);
0098
0099
0100
0101 _gsl_matrix_char_view
0102 gsl_matrix_char_submatrix (gsl_matrix_char * m,
0103 const size_t i, const size_t j,
0104 const size_t n1, const size_t n2);
0105
0106 _gsl_vector_char_view
0107 gsl_matrix_char_row (gsl_matrix_char * m, const size_t i);
0108
0109 _gsl_vector_char_view
0110 gsl_matrix_char_column (gsl_matrix_char * m, const size_t j);
0111
0112 _gsl_vector_char_view
0113 gsl_matrix_char_diagonal (gsl_matrix_char * m);
0114
0115 _gsl_vector_char_view
0116 gsl_matrix_char_subdiagonal (gsl_matrix_char * m, const size_t k);
0117
0118 _gsl_vector_char_view
0119 gsl_matrix_char_superdiagonal (gsl_matrix_char * m, const size_t k);
0120
0121 _gsl_vector_char_view
0122 gsl_matrix_char_subrow (gsl_matrix_char * m, const size_t i,
0123 const size_t offset, const size_t n);
0124
0125 _gsl_vector_char_view
0126 gsl_matrix_char_subcolumn (gsl_matrix_char * m, const size_t j,
0127 const size_t offset, const size_t n);
0128
0129 _gsl_matrix_char_view
0130 gsl_matrix_char_view_array (char * base,
0131 const size_t n1,
0132 const size_t n2);
0133
0134 _gsl_matrix_char_view
0135 gsl_matrix_char_view_array_with_tda (char * base,
0136 const size_t n1,
0137 const size_t n2,
0138 const size_t tda);
0139
0140
0141 _gsl_matrix_char_view
0142 gsl_matrix_char_view_vector (gsl_vector_char * v,
0143 const size_t n1,
0144 const size_t n2);
0145
0146 _gsl_matrix_char_view
0147 gsl_matrix_char_view_vector_with_tda (gsl_vector_char * v,
0148 const size_t n1,
0149 const size_t n2,
0150 const size_t tda);
0151
0152
0153 _gsl_matrix_char_const_view
0154 gsl_matrix_char_const_submatrix (const gsl_matrix_char * m,
0155 const size_t i, const size_t j,
0156 const size_t n1, const size_t n2);
0157
0158 _gsl_vector_char_const_view
0159 gsl_matrix_char_const_row (const gsl_matrix_char * m,
0160 const size_t i);
0161
0162 _gsl_vector_char_const_view
0163 gsl_matrix_char_const_column (const gsl_matrix_char * m,
0164 const size_t j);
0165
0166 _gsl_vector_char_const_view
0167 gsl_matrix_char_const_diagonal (const gsl_matrix_char * m);
0168
0169 _gsl_vector_char_const_view
0170 gsl_matrix_char_const_subdiagonal (const gsl_matrix_char * m,
0171 const size_t k);
0172
0173 _gsl_vector_char_const_view
0174 gsl_matrix_char_const_superdiagonal (const gsl_matrix_char * m,
0175 const size_t k);
0176
0177 _gsl_vector_char_const_view
0178 gsl_matrix_char_const_subrow (const gsl_matrix_char * m, const size_t i,
0179 const size_t offset, const size_t n);
0180
0181 _gsl_vector_char_const_view
0182 gsl_matrix_char_const_subcolumn (const gsl_matrix_char * m, const size_t j,
0183 const size_t offset, const size_t n);
0184
0185 _gsl_matrix_char_const_view
0186 gsl_matrix_char_const_view_array (const char * base,
0187 const size_t n1,
0188 const size_t n2);
0189
0190 _gsl_matrix_char_const_view
0191 gsl_matrix_char_const_view_array_with_tda (const char * base,
0192 const size_t n1,
0193 const size_t n2,
0194 const size_t tda);
0195
0196 _gsl_matrix_char_const_view
0197 gsl_matrix_char_const_view_vector (const gsl_vector_char * v,
0198 const size_t n1,
0199 const size_t n2);
0200
0201 _gsl_matrix_char_const_view
0202 gsl_matrix_char_const_view_vector_with_tda (const gsl_vector_char * v,
0203 const size_t n1,
0204 const size_t n2,
0205 const size_t tda);
0206
0207
0208
0209 void gsl_matrix_char_set_zero (gsl_matrix_char * m);
0210 void gsl_matrix_char_set_identity (gsl_matrix_char * m);
0211 void gsl_matrix_char_set_all (gsl_matrix_char * m, char x);
0212
0213 int gsl_matrix_char_fread (FILE * stream, gsl_matrix_char * m) ;
0214 int gsl_matrix_char_fwrite (FILE * stream, const gsl_matrix_char * m) ;
0215 int gsl_matrix_char_fscanf (FILE * stream, gsl_matrix_char * m);
0216 int gsl_matrix_char_fprintf (FILE * stream, const gsl_matrix_char * m, const char * format);
0217
0218 int gsl_matrix_char_memcpy(gsl_matrix_char * dest, const gsl_matrix_char * src);
0219 int gsl_matrix_char_swap(gsl_matrix_char * m1, gsl_matrix_char * m2);
0220 int gsl_matrix_char_tricpy(CBLAS_UPLO_t Uplo, CBLAS_DIAG_t Diag, gsl_matrix_char * dest, const gsl_matrix_char * src);
0221
0222 int gsl_matrix_char_swap_rows(gsl_matrix_char * m, const size_t i, const size_t j);
0223 int gsl_matrix_char_swap_columns(gsl_matrix_char * m, const size_t i, const size_t j);
0224 int gsl_matrix_char_swap_rowcol(gsl_matrix_char * m, const size_t i, const size_t j);
0225 int gsl_matrix_char_transpose (gsl_matrix_char * m);
0226 int gsl_matrix_char_transpose_memcpy (gsl_matrix_char * dest, const gsl_matrix_char * src);
0227 int gsl_matrix_char_transpose_tricpy (CBLAS_UPLO_t Uplo_src, CBLAS_DIAG_t Diag, gsl_matrix_char * dest, const gsl_matrix_char * src);
0228
0229 char gsl_matrix_char_max (const gsl_matrix_char * m);
0230 char gsl_matrix_char_min (const gsl_matrix_char * m);
0231 void gsl_matrix_char_minmax (const gsl_matrix_char * m, char * min_out, char * max_out);
0232
0233 void gsl_matrix_char_max_index (const gsl_matrix_char * m, size_t * imax, size_t *jmax);
0234 void gsl_matrix_char_min_index (const gsl_matrix_char * m, size_t * imin, size_t *jmin);
0235 void gsl_matrix_char_minmax_index (const gsl_matrix_char * m, size_t * imin, size_t * jmin, size_t * imax, size_t * jmax);
0236
0237 int gsl_matrix_char_equal (const gsl_matrix_char * a, const gsl_matrix_char * b);
0238
0239 int gsl_matrix_char_isnull (const gsl_matrix_char * m);
0240 int gsl_matrix_char_ispos (const gsl_matrix_char * m);
0241 int gsl_matrix_char_isneg (const gsl_matrix_char * m);
0242 int gsl_matrix_char_isnonneg (const gsl_matrix_char * m);
0243
0244 char gsl_matrix_char_norm1 (const gsl_matrix_char * m);
0245
0246 int gsl_matrix_char_add (gsl_matrix_char * a, const gsl_matrix_char * b);
0247 int gsl_matrix_char_sub (gsl_matrix_char * a, const gsl_matrix_char * b);
0248 int gsl_matrix_char_mul_elements (gsl_matrix_char * a, const gsl_matrix_char * b);
0249 int gsl_matrix_char_div_elements (gsl_matrix_char * a, const gsl_matrix_char * b);
0250 int gsl_matrix_char_scale (gsl_matrix_char * a, const char x);
0251 int gsl_matrix_char_scale_rows (gsl_matrix_char * a, const gsl_vector_char * x);
0252 int gsl_matrix_char_scale_columns (gsl_matrix_char * a, const gsl_vector_char * x);
0253 int gsl_matrix_char_add_constant (gsl_matrix_char * a, const char x);
0254 int gsl_matrix_char_add_diagonal (gsl_matrix_char * a, const char x);
0255
0256
0257
0258
0259 int gsl_matrix_char_get_row(gsl_vector_char * v, const gsl_matrix_char * m, const size_t i);
0260 int gsl_matrix_char_get_col(gsl_vector_char * v, const gsl_matrix_char * m, const size_t j);
0261 int gsl_matrix_char_set_row(gsl_matrix_char * m, const size_t i, const gsl_vector_char * v);
0262 int gsl_matrix_char_set_col(gsl_matrix_char * m, const size_t j, const gsl_vector_char * v);
0263
0264
0265
0266
0267 INLINE_DECL char gsl_matrix_char_get(const gsl_matrix_char * m, const size_t i, const size_t j);
0268 INLINE_DECL void gsl_matrix_char_set(gsl_matrix_char * m, const size_t i, const size_t j, const char x);
0269 INLINE_DECL char * gsl_matrix_char_ptr(gsl_matrix_char * m, const size_t i, const size_t j);
0270 INLINE_DECL const char * gsl_matrix_char_const_ptr(const gsl_matrix_char * m, const size_t i, const size_t j);
0271
0272 #ifdef HAVE_INLINE
0273 INLINE_FUN
0274 char
0275 gsl_matrix_char_get(const gsl_matrix_char * m, const size_t i, const size_t j)
0276 {
0277 #if GSL_RANGE_CHECK
0278 if (GSL_RANGE_COND(1))
0279 {
0280 if (i >= m->size1)
0281 {
0282 GSL_ERROR_VAL("first index out of range", GSL_EINVAL, 0) ;
0283 }
0284 else if (j >= m->size2)
0285 {
0286 GSL_ERROR_VAL("second index out of range", GSL_EINVAL, 0) ;
0287 }
0288 }
0289 #endif
0290 return m->data[i * m->tda + j] ;
0291 }
0292
0293 INLINE_FUN
0294 void
0295 gsl_matrix_char_set(gsl_matrix_char * m, const size_t i, const size_t j, const char x)
0296 {
0297 #if GSL_RANGE_CHECK
0298 if (GSL_RANGE_COND(1))
0299 {
0300 if (i >= m->size1)
0301 {
0302 GSL_ERROR_VOID("first index out of range", GSL_EINVAL) ;
0303 }
0304 else if (j >= m->size2)
0305 {
0306 GSL_ERROR_VOID("second index out of range", GSL_EINVAL) ;
0307 }
0308 }
0309 #endif
0310 m->data[i * m->tda + j] = x ;
0311 }
0312
0313 INLINE_FUN
0314 char *
0315 gsl_matrix_char_ptr(gsl_matrix_char * m, const size_t i, const size_t j)
0316 {
0317 #if GSL_RANGE_CHECK
0318 if (GSL_RANGE_COND(1))
0319 {
0320 if (i >= m->size1)
0321 {
0322 GSL_ERROR_NULL("first index out of range", GSL_EINVAL) ;
0323 }
0324 else if (j >= m->size2)
0325 {
0326 GSL_ERROR_NULL("second index out of range", GSL_EINVAL) ;
0327 }
0328 }
0329 #endif
0330 return (char *) (m->data + (i * m->tda + j)) ;
0331 }
0332
0333 INLINE_FUN
0334 const char *
0335 gsl_matrix_char_const_ptr(const gsl_matrix_char * m, const size_t i, const size_t j)
0336 {
0337 #if GSL_RANGE_CHECK
0338 if (GSL_RANGE_COND(1))
0339 {
0340 if (i >= m->size1)
0341 {
0342 GSL_ERROR_NULL("first index out of range", GSL_EINVAL) ;
0343 }
0344 else if (j >= m->size2)
0345 {
0346 GSL_ERROR_NULL("second index out of range", GSL_EINVAL) ;
0347 }
0348 }
0349 #endif
0350 return (const char *) (m->data + (i * m->tda + j)) ;
0351 }
0352
0353 #endif
0354
0355 __END_DECLS
0356
0357 #endif