1 #include <../../nrnconf.h> 33 static char rcsid[] =
"zmatio.c,v 1.1 1997/12/04 17:56:11 hines Exp";
51 if ( isatty(fileno(
fp)) )
54 fprintf(stderr,
"real and imag parts: ");
58 io_code = sscanf(
line,
"%lf%lf",&z.
re,&z.
im);
60 io_code = sscanf(
line,
"%f%f",&z.
re,&z.
im);
63 }
while ( io_code != 2 );
67 if ( (io_code=fscanf(
fp,
" (%lf,%lf)",&z.
re,&z.
im)) < 2 )
69 if ( (io_code=fscanf(
fp,
" (%f,%f)",&z.
re,&z.
im)) < 2 )
83 if ( isatty(fileno(
fp)) )
100 { m = mat->
m; n = mat->
n; dynamic =
FALSE; }
106 fprintf(stderr,
"ComplexMatrix: rows cols:");
114 for ( i=0; i<m; i++ )
118 for ( j=0; j<
n; j++ )
122 fprintf(stderr,
"entry (%u,%u): ",i,j);
124 fprintf(stderr,
"old (%14.9g,%14.9g) new: ",
128 if ( (*
line ==
'b' || *
line ==
'B') && j > 0 )
129 { j--; dynamic =
FALSE;
goto redo2; }
130 if ( (*
line ==
'f' || *
line ==
'F') && j < n-1 )
131 { j++; dynamic =
FALSE;
goto redo2; }
132 }
while ( *
line==
'\0' ||
134 sscanf(
line,
"%lf%lf",
138 &mat->
me[i][j].
re,&mat->
me[i][j].
im)<1 );
141 if ( c ==
'n' || c ==
'N' )
142 { dynamic =
FALSE;
goto redo; }
143 if ( (c ==
'b' || c ==
'B') )
146 dynamic =
FALSE;
goto redo;
163 if ((io_code=fscanf(
fp,
" ComplexMatrix: %u by %u",&m,&n)) < 2 ||
168 if ( mat==
ZMNULL || mat->
m<m || mat->
n<n )
172 for ( i=0; i<m; i++ )
175 if ( fscanf(
fp,
" row %u:",&dummy) < 1 )
176 error(E_FORMAT,
"bzm_finput");
177 for ( j=0; j<
n; j++ )
181 if ((io_code=fscanf(
fp,
" ( %lf , %lf )",
183 if ((io_code=fscanf(
fp,
" ( %f , %f )",
185 &mat->
me[i][j].
re,&mat->
me[i][j].
im)) < 2 )
186 error(io_code==EOF ?
E_EOF : E_FORMAT,
"bzm_finput");
199 if ( isatty(fileno(
fp)) )
214 { dim = vec->
dim; dynamic =
FALSE; }
220 fprintf(stderr,
"ComplexVector: dim: ");
223 }
while ( sscanf(
line,
"%u",&dim)<1 || dim>
MAXDIM );
228 for ( i=0; i<dim; i++ )
232 fprintf(stderr,
"entry %u: ",i);
234 fprintf(stderr,
"old (%14.9g,%14.9g) new: ",
238 if ( (*
line ==
'b' || *
line ==
'B') && i > 0 )
239 { i--; dynamic =
FALSE;
goto redo; }
240 if ( (*
line ==
'f' || *
line ==
'F') && i < dim-1 )
241 { i++; dynamic =
FALSE;
goto redo; }
242 }
while ( *
line==
'\0' ||
244 sscanf(
line,
"%lf%lf",
248 &vec->
ve[i].
re,&vec->
ve[i].
im) < 2 );
263 if ((io_code=fscanf(
fp,
" ComplexVector: dim:%u",&dim)) < 1 ||
265 error(io_code==EOF ? 7 : 6,
"bzv_finput");
274 for ( i=0; i<dim; i++ )
276 if ((io_code=fscanf(
fp,
" (%lf,%lf)",
278 if ((io_code=fscanf(
fp,
" (%f,%f)",
280 &vec->
ve[i].
re,&vec->
ve[i].
im)) < 2 )
281 error(io_code==EOF ? 7 : 6,
"bzv_finput");
296 if ( f_string != (
char *)
NULL && *f_string !=
'\0' )
317 {
fprintf(
fp,
"ComplexMatrix: NULL\n");
return; }
321 for ( i=0; i<a->
m; i++ )
324 for ( j=0, tmp=1; j<a->
n; j++, tmp++ )
327 if ( ! (tmp % 2) ) putc(
'\n',
fp);
329 if ( tmp % 2 != 1 ) putc(
'\n',
fp);
340 {
fprintf(
fp,
"ComplexVector: NULL\n");
return; }
344 for ( i=0, tmp=0; i<x->
dim; i++, tmp++ )
347 if ( (tmp % 2) == 1 ) putc(
'\n',
fp);
349 if ( (tmp % 2) != 0 ) putc(
'\n',
fp);
360 {
fprintf(
fp,
"ComplexMatrix: NULL\n");
return; }
361 fprintf(
fp,
"ComplexMatrix: %d by %d @ 0x%p\n",a->
m,a->
n,a);
362 fprintf(
fp,
"\tmax_m = %d, max_n = %d, max_size = %d\n",
368 for ( i=0; i<a->
m; i++ )
371 for ( j=0, tmp=1; j<a->
n; j++, tmp++ )
374 if ( ! (tmp % 2) ) putc(
'\n',
fp);
376 if ( tmp % 2 != 1 ) putc(
'\n',
fp);
389 {
fprintf(
fp,
"ComplexVector: NULL\n");
return; }
390 fprintf(
fp,
"ComplexVector: dim: %d @ 0x%p\n",x->
dim,(x));
394 for ( i=0, tmp=0; i<x->
dim; i++, tmp++ )
397 if ( tmp % 2 == 1 ) putc(
'\n',
fp);
399 if ( tmp % 2 != 0 ) putc(
'\n',
fp);
char * setzformat(char *f_string)
ZMAT * bzm_finput(FILE *fp, ZMAT *mat)
ZVEC * bzv_finput(FILE *fp, ZVEC *vec)
ZMAT * izm_finput(FILE *fp, ZMAT *mat)
static char line[MAXLINE]
ZMAT * zm_resize(ZMAT *A, int new_m, int new_n)
int const size_t const size_t n
complex z_finput(FILE *fp)
ZMAT * zm_finput(FILE *fp, ZMAT *a)
fprintf(stderr, "Don't know the location of params at %p\, pp)
ZVEC * zv_finput(FILE *fp, ZVEC *x)
ZVEC * izv_finput(FILE *fp, ZVEC *vec)
ZMAT * zm_get(int m, int n)
ZVEC * zv_resize(ZVEC *x, int new_dim)
void zm_foutput(FILE *fp, ZMAT *a)
void zv_foutput(FILE *fp, ZVEC *x)
#define error(err_num, fn_name)
void z_foutput(FILE *fp, complex z)
void zv_dump(FILE *fp, ZVEC *x)
void zm_dump(FILE *fp, ZMAT *a)