diff options
author | Alberto Ruiz <aruiz@um.es> | 2009-06-17 20:52:14 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2009-06-17 20:52:14 +0000 |
commit | 5db2ed78986bbc737b82e428392ee63999c8abfd (patch) | |
tree | 45d95942c831c25a5adbc88e8b266fac0c6ce87e /lib/Numeric/GSL/gsl-aux.c | |
parent | e58f1e0e94407983fa18cd535cf76427019f1519 (diff) |
vector fread/fwrite, fscanf/fprinf
Diffstat (limited to 'lib/Numeric/GSL/gsl-aux.c')
-rw-r--r-- | lib/Numeric/GSL/gsl-aux.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/lib/Numeric/GSL/gsl-aux.c b/lib/Numeric/GSL/gsl-aux.c index 0904a67..b3b524d 100644 --- a/lib/Numeric/GSL/gsl-aux.c +++ b/lib/Numeric/GSL/gsl-aux.c | |||
@@ -1,4 +1,15 @@ | |||
1 | #include "gsl-aux.h" | 1 | #include <gsl/gsl_complex.h> |
2 | |||
3 | #define RVEC(A) int A##n, double*A##p | ||
4 | #define RMAT(A) int A##r, int A##c, double* A##p | ||
5 | #define KRVEC(A) int A##n, const double*A##p | ||
6 | #define KRMAT(A) int A##r, int A##c, const double* A##p | ||
7 | |||
8 | #define CVEC(A) int A##n, gsl_complex*A##p | ||
9 | #define CMAT(A) int A##r, int A##c, gsl_complex* A##p | ||
10 | #define KCVEC(A) int A##n, const gsl_complex*A##p | ||
11 | #define KCMAT(A) int A##r, int A##c, const gsl_complex* A##p | ||
12 | |||
2 | #include <gsl/gsl_blas.h> | 13 | #include <gsl/gsl_blas.h> |
3 | #include <gsl/gsl_math.h> | 14 | #include <gsl/gsl_math.h> |
4 | #include <gsl/gsl_errno.h> | 15 | #include <gsl/gsl_errno.h> |
@@ -8,7 +19,6 @@ | |||
8 | #include <gsl/gsl_poly.h> | 19 | #include <gsl/gsl_poly.h> |
9 | #include <gsl/gsl_multimin.h> | 20 | #include <gsl/gsl_multimin.h> |
10 | #include <gsl/gsl_multiroots.h> | 21 | #include <gsl/gsl_multiroots.h> |
11 | #include <gsl/gsl_complex.h> | ||
12 | #include <gsl/gsl_complex_math.h> | 22 | #include <gsl/gsl_complex_math.h> |
13 | #include <string.h> | 23 | #include <string.h> |
14 | #include <stdio.h> | 24 | #include <stdio.h> |
@@ -340,13 +350,45 @@ int polySolve(KRVEC(a), CVEC(z)) { | |||
340 | OK; | 350 | OK; |
341 | } | 351 | } |
342 | 352 | ||
343 | int matrix_fscanf(char*filename, RMAT(a)) { | 353 | int vector_fscanf(char*filename, RVEC(a)) { |
344 | DEBUGMSG("gsl_matrix_fscanf"); | 354 | DEBUGMSG("gsl_matrix_fscanf"); |
345 | //printf(filename); printf("\n"); | 355 | DVVIEW(a); |
346 | DMVIEW(a); | ||
347 | FILE * f = fopen(filename,"r"); | 356 | FILE * f = fopen(filename,"r"); |
348 | CHECK(!f,BAD_FILE); | 357 | CHECK(!f,BAD_FILE); |
349 | int res = gsl_matrix_fscanf(f, M(a)); | 358 | int res = gsl_vector_fscanf(f,V(a)); |
359 | CHECK(res,res); | ||
360 | fclose (f); | ||
361 | OK | ||
362 | } | ||
363 | |||
364 | int vector_fprintf(char*filename, char*fmt, RVEC(a)) { | ||
365 | DEBUGMSG("gsl_vector_fprintf"); | ||
366 | DVVIEW(a); | ||
367 | FILE * f = fopen(filename,"w"); | ||
368 | CHECK(!f,BAD_FILE); | ||
369 | int res = gsl_vector_fprintf(f,V(a),fmt); | ||
370 | CHECK(res,res); | ||
371 | fclose (f); | ||
372 | OK | ||
373 | } | ||
374 | |||
375 | int vector_fread(char*filename, RVEC(a)) { | ||
376 | DEBUGMSG("gsl_matrix_fscanf"); | ||
377 | DVVIEW(a); | ||
378 | FILE * f = fopen(filename,"r"); | ||
379 | CHECK(!f,BAD_FILE); | ||
380 | int res = gsl_vector_fread(f,V(a)); | ||
381 | CHECK(res,res); | ||
382 | fclose (f); | ||
383 | OK | ||
384 | } | ||
385 | |||
386 | int vector_fwrite(char*filename, RVEC(a)) { | ||
387 | DEBUGMSG("gsl_vector_fprintf"); | ||
388 | DVVIEW(a); | ||
389 | FILE * f = fopen(filename,"w"); | ||
390 | CHECK(!f,BAD_FILE); | ||
391 | int res = gsl_vector_fwrite(f,V(a)); | ||
350 | CHECK(res,res); | 392 | CHECK(res,res); |
351 | fclose (f); | 393 | fclose (f); |
352 | OK | 394 | OK |