summaryrefslogtreecommitdiff
path: root/lib/Numeric/GSL
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2009-06-17 20:52:14 +0000
committerAlberto Ruiz <aruiz@um.es>2009-06-17 20:52:14 +0000
commit5db2ed78986bbc737b82e428392ee63999c8abfd (patch)
tree45d95942c831c25a5adbc88e8b266fac0c6ce87e /lib/Numeric/GSL
parente58f1e0e94407983fa18cd535cf76427019f1519 (diff)
vector fread/fwrite, fscanf/fprinf
Diffstat (limited to 'lib/Numeric/GSL')
-rw-r--r--lib/Numeric/GSL/gsl-aux.c54
-rw-r--r--lib/Numeric/GSL/gsl-aux.h40
2 files changed, 48 insertions, 46 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
343int matrix_fscanf(char*filename, RMAT(a)) { 353int 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
364int 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
375int 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
386int 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
diff --git a/lib/Numeric/GSL/gsl-aux.h b/lib/Numeric/GSL/gsl-aux.h
deleted file mode 100644
index 881d0d0..0000000
--- a/lib/Numeric/GSL/gsl-aux.h
+++ /dev/null
@@ -1,40 +0,0 @@
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
13void no_abort_on_error();
14
15int toScalarR(int code, KRVEC(x), RVEC(r));
16/* norm2, absdif, maximum, posmax, etc. */
17
18int mapR(int code, KRVEC(x), RVEC(r));
19int mapC(int code, KCVEC(x), CVEC(r));
20/* sin cos tan etc. */
21
22int mapValR(int code, double*, KRVEC(x), RVEC(r));
23int mapValC(int code, gsl_complex*, KCVEC(x), CVEC(r));
24
25int zipR(int code, KRVEC(a), KRVEC(b), RVEC(r));
26int zipC(int code, KCVEC(a), KCVEC(b), CVEC(r));
27
28
29int fft(int code, KCVEC(a), CVEC(b));
30
31int deriv(int code, double f(double, void*), double x, double h, double * result, double * abserr);
32
33int integrate_qng(double f(double, void*), double a, double b, double prec,
34 double *result, double*error);
35
36int integrate_qags(double f(double,void*), double a, double b, double prec, int w,
37 double *result, double* error);
38
39int polySolve(KRVEC(a), CVEC(z));
40