home *** CD-ROM | disk | FTP | other *** search
- & Zbigniew Leyk, all rights reserved.
- **
- ** Meschach Library
- **
- ** This Meschach Library is provided "as is" without any express
- ** or implied warranty of any kind with respect to this software.
- ** In particular the authors shall not be liable for any direct,
- ** indirect, special, incidental or consequential damages arising
- ** in any way from use of the software.
- **
- ** Everyone is granted permission to copy, modify and redistribute this
- ** Meschach Library, provided:
- ** 1. All copies contain this copyright notice.
- ** 2. All modified copies shall carry a notice stating who
- ** made the last modification and the date of such modification.
- ** 3. No charge is made for this software or works derived from it.
- ** This clause shall not be construed as constraining other software
- ** distributed on the same medium as this software, nor is a
- ** distribution fee considered a charge.
- **
- ***************************************************************************/
-
-
- /*
- This file contains routines for import/exporting data to/from
- MATLAB. The main routines are:
- MAT *m_save(FILE *fp,MAT *A,char *name)
- VEC *v_save(FILE *fp,VEC *x,char *name)
- MAT *m_load(FILE *fp,char **name)
- */
-
- #include <stdio.h>
- #include "matrix.h"
- #include "matlab.h"
-
- static char rcsid[] = "$Id: matlab.c,v 1.7 1994/01/13 05:30:09 des Exp $";
-
- /* m_save -- save matrix in ".mat" file for MATLAB
- -- returns matrix to be saved */
- MAT *m_save(fp,A,name)
- FILE *fp;
- MAT *A;
- char *name;
- {
- int i;
- matlab mat;
-
- if ( ! A )
- error(E_NULL,"m_save");
-
- mat.type = 1000*MACH_ID + 100*ORDER + 10*PRECISION + 0;
- mat.m = A->m;
- mat.n = A->n;
- mat.imag = FALSE;
- mat.namlen = (name == (char *)NULL) ? 1 : strlen(name)+1;
-
- /* write header */
- fwrite(&mat,sizeof(matlab),1,fp);
- /* write name */
- if ( name == (char *)NULL )
- fwrite("",sizeof(char),1,fp);
- else
- fwrite(name,sizeof(char),(int)(mat.namlen),fp);
- /* write actual data */
- for ( i = 0; i < A->m; i++ )
- fwrite(A->me[i],sizeof(Real),(int)(A->n),fp);
-
- return A;
- }
-
-
- /* v_save -- save vector in ".mat" file for MATLAB
- -- saves it as a row vector
- -- returns vector to be saved */
- VEC *v_save(fp,x,name)
- FILE *fp;
- VEC *x;
- char *name;
- {
- matlab mat;
-
- if ( ! x )
- error(E_NULL,"v_save");
-
- mat.type = 1000*MACH_ID + 100*ORDER + 10*PRECISION + 0;
- mat.m = x->dim;
- mat.n = 1;
- mat.imag = FALSE;
- mat.namlen = (name == (char *)NULL) ? 1 : strlen(name)+1;
-
- /* write header */
- fwrite(&mat,sizeof(matlab),1,fp);
- /* write name */
- if ( name == (char *)NULL )
- fwrite("",sizeof(char),1,fp);
- else
- fwrite(name,sizeof(char),(int)(mat.namlen),fp);
- /* write actual data */
- fwrite(x->ve,sizeof(Real),(int)(x->dim),fp);
-
- return x;
- }
-
- /* d_save -- save double in ".mat" file for MATLAB
- -- saves it as a row vector
- -- returns vector to be saved */
- double d_save(fp,x,name)
- FILE *fp;
- double x;
- char *name;
- {
- matlab mat;
- Real x1 = x;
-
- mat.type = 1000*MACH_ID + 100*ORDER + 10*PRECISION + 0;
- mat.m = 1;
- mat.n = 1;
- mat.imag = FALSE;
- mat.namlen = (name == (char *)NULL) ? 1 : strlen(name)+1;
-
- /* write header */
- fwrite(&mat,sizeof(matlab),1,fp);
- /* write name */
- if ( name == (char *)NULL )
- fwrite("",sizeof(char),1,fp);
- else
- fwrite(name,sizeof(char),(int)(mat.namlen),fp);
- /* write actual data */
- fwrite(&x1,sizeof(Real),1,fp);
-
- return x;
- }
-
- /* m_load -- loads in a ".mat" file variable as produced by MATLAB
- -- matrix returned; imaginary parts ignored */
- MAT *m_load(fp,name)
- FILE *fp;
- char **name;
- {
- MAT *A;
- int i;
- int m_flag, o_flag, p_flag, t_flag;
- float f_temp;
- Real d_temp;
- matlab mat;
-
- if ( fread(&mat,sizeof(matlab),1,fp) != 1 )
- error(E_FORMAT,"m_load");
- if ( mat.type >= 10000 ) /* don't load a sparse matrix! */
- error(E_FORMAT,"m_load");
- m_flag = (mat.type/1000) % 10;
- o_flag = (mat.type/100) % 10;
- p_flag = (mat.type/10) % 10;
- t_flag = (mat.type) % 10;
- if ( m_flag != MACH_ID )
- error(E_FORMAT,"m_load");
- if ( t_flag != 0 )
- error(E_FORMAT,"m_load");
- if ( p_flag != DOUBLE_PREC && p_flag != SINGLE_PREC )
- error(E_FORMAT,"m_load");
- *name = (char *)malloc((unsigned)(mat.namlen)+1);
- if ( fread(*name,sizeof(char),(unsigned)(mat.namlen),fp) == 0 )
- error(E_FORMAT,"m_load");
- A = m_get((unsigned)(mat.m),(unsigned)(mat.n));
- for ( i = 0; i < A->m*A->n; i++ )
- {
- if ( p_flag == DOUBLE_PREC )
- fread(&d_temp,sizeof(double),1,fp);
- else
- {
- fread(&f_temp,sizeof(float),1,fp);
- d_temp = f_temp;
- }
- if ( o_flag == ROW_ORDER )
- A->me[i / A->n][i % A->n] = d_temp;
- else if ( o_flag == COL_ORDER )
- A->me[i % A->m][i / A->m] = d_temp;
- else
- error(E_FORMAT,"m_load");
- }
-
- if ( mat.imag ) /* skip imaginary part */
- for ( i = 0; i < A->m*A->n; i++ )
- {
- if ( p_flag == DOUBLE_PREC )
- fread(&d_temp,sizeof(double),1,fp);
- else
- fread(&f_temp,sizeof(float),1,fp);
- }
-
- return A;
- }
-
- FileDataŵmatop î. Eÿÿÿd…? ◰.
- /**************************************************************************
- **
- ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
- **
- ** Meschach Library
- **
- ** This Meschach Library is provided "as is" without any express
- ** or implied warranty of any kind with respect to this software.
- ** In particular the authors shall not be liable for any direct,
- ** indirect, special, incidental or consequential damages arising
- ** in any way from use of the software.
- **
- ** Everyone is granted permission to copy, modify and redistribute this
- ** Meschach Library, provided:
- ** 1. All copies contain this copyright notice.
- ** 2. All modified copies shall carry a notice stating who
- ** made the last modification and the date of such modification.
- ** 3. No charge is made for this software or works derived from it.
- ** This clause shall not be construed as constraining other software
- ** distributed on the same medium as this software, nor is a
- ** distribution fee considered a charge.
- **
- ***************************************************************************/
-
-
- /* matop.c 1.3 11/25/87 */
-
-
- #include <stdio.h>
- #include "matrix.h"
-
- static char rcsid[] = "$Id: matop.c,v 1.3 1994/01/13 05:30:28 des Exp $";
-
-
- /* m_add -- matrix addition -- may be in-situ */
- MAT *m_add(mat1,mat2,out)
- MAT *mat1,*mat2,*out;
- {
- u_int m,n,i;
-
- if ( mat1==(MAT *)NULL || mat2==(MAT *)NULL )
- error(E_NULL,"m_add");
- if ( mat1->m != mat2->m || mat1->n != mat2->n )
- error(E_SIZES,"m_add");
- if ( out==(MAT *)NULL || out->m != mat1->m || out->n != mat1->n )
- out = m_resize(out,mat1->m,mat1->n);
- m = mat1->m; n = mat1->n;
- for ( i=0; i<m; i++ )
- {
- __add__(mat1->me[i],mat2->me[i],out->me[i],(int)n);
- /**************************************************
- for ( j=0; j<n; j++ )
- out->me[i][j] = mat1->me[i][j]+mat2->me[i][j];
- **************************************************/
- }
-
- return (out);
- }
-
- /* m_sub -- matrix subtraction -- may be in-situ */
- MAT *m_sub(mat1,mat2,out)
- MAT *mat1,*mat2,*out;
- {
- u_int m,n,i;
-
- if ( mat1==(MAT *)NULL || mat2==(MAT *)NULL )
- error(E_NULL,"m_sub");
- if ( mat1->m != mat2->m || mat1->n != mat2->n )
- e for any direct,
- ** indirect, special, incidental or consequential damages arising
- ** in any way from use of the software.
- **
- ** Everyone is granted permission to copy, modify and redistribute this
- ** Meschach Library, provided:
- ** 1. All copies contain this copyright notice.
- ** 2. All modified copies shall carry a notice stating who
- ** made the last modification and the date of such modification.
- ** 3. No charge is made for this software or works derived from it.
- ** This clause shall not be construed as constraining other software
- ** distributed on the same medium as this software, nor is a
- ** distribution fee considered a charge.
- **
- ***************************************************************************/
-
-
- /*
- Files for matrix computations
-
- Householder transformation file. Contains routines for calculating
- householder transformations, applying them to vectors and matrices
- by both row & column.
- */
-
- /* hsehldr.c 1.3 10/8/87 */
- static char rcsid[] = "$Id: hsehldr.c,v 1.2 1994/01/13 05:36:29 des Exp $";
-
- #include <stdio.h>
- #include <math.h>
- #include "matrix.h"
- #include "matrix2.h"
-
-
- /* hhvec -- calulates Householder vector to eliminate all entries after the
- i0 entry of the vector vec. It is returned as out. May be in-situ */
- VEC *hhvec(vec,i0,beta,out,newval)
- VEC *vec,*out;
- u_int i0;
- Real *beta,*newval;
- {
- Real norm;
-
- out = _v_copy(vec,out,i0);
- norm = sqrt(_in_prod(out,out,i0));
- if ( norm <= 0.0 )
- {
- *beta = 0.0;
- return (out);
- }
- *beta = 1.0/(norm * (norm+fabs(out->ve[i0])));
- if ( out->ve[i0] > 0.0 )
- *newval = -norm;
- else
- *newval = norm;
- out->ve[i0] -= *newval;
-
- return (out);
- }
-
- /* hhtrvec -- apply Householder transformation to vector -- may be in-situ */
- VEC *hhtrvec(hh,beta,i0,in,out)
- VEC *hh,*in,*out; /* hh = Householder vector */
- u_int i0;
- double beta;
- {
- Real scale;
- /* u_int i; */
-
- if ( hh==(VEC *)NULL || in==(VEC *)NULL )
- error(E_NULL,"hhtrvec");
- if ( in->dim != hh->dim )
- error(E_SIZES,"hhtrvec");
- if ( i0 > in->dim )
- error(E_BOUNDS,"hhtrvec");
-
- scale = beta*_in_prod(hh,in,i0);
- out = v_copy(in,out);
- __mltadd__(&(out->ve[i0]),&(hh->ve[i0]),-scale,(int)(in->dim-i0));
- /************************************************************
- for ( i=i0; i<in->dim; i++ )
- out->ve[i] = in->ve[i] - scale*hh->ve[i];
- ************************************************************/
-
- return (out);
- }
-
- /* hhtrrows -- transform a matrix by a Householder vector by rows
- starting at row i0 from column j0 -- in-situ */
- MAT *hhtrrows(M,i0,j0,hh,beta)
- MAT *M;
- u_int i0, j0;
- VEC *hh;
- double beta;
- {
- Real ip, scale;
- int i /*, j */;
-
- if ( M==(MAT *)NULL || hh==(VEC *)NULL )
- error(E_NULL,"hhtrrows");
- if ( M->n != hh->dim )
- error(E_RANGE,"hhtrrows");
- if ( i0 > M->m || j0 > M->n )
- error(E_BOUNDS,"hhtrrows");
-
- if ( beta == 0.0 ) return (M);
-
- /* for each row ... */
- for ( i = i0; i < M->m; i++ )
- { /* compute inner product */
- ip = __ip__(&(M->me[i][j0]),&(hh->ve[j0]),(int)(M->n-j0));
- /**************************************************
- ip = 0.0;
- for ( j = j0; j < M->n; j++ )
- ip += M->me[i][j]*hh->ve[j];
- **************************************************/
- scale = beta*ip;
- if ( scale == 0.0 )
- continue;
-
- /* do operation */
- __mltadd__(&(M->me[i][j0]),&(hh->ve[j0]),-scale,
- (int)(M->n-j0));
- /**************************************************
- for ( j = j0; j < M->n; j++ )
- M->me[i][j] -= scale*hh->ve[j];
- **************************************************/
- }
-
- return (M);
- }
-
-
- /* hhtrcols -- transform a matrix by a Householder vector by columns
- starting at row i0 from column j0 -- in-situ */
- MAT *hhtrcols(M,i0,j0,hh,beta)
- MAT *M;
- u_int i0, j0;
- VEC *hh;
- double beta;
- {
- /* Real ip, scale; */
- int i /*, k */;
- static VEC *w = VNULL;
-
- if ( M==(MAT *)NULL || hh==(VEC *)NULL )
- error(E_NULL,"hhtrcols");
- if ( M->m != hh->dim )
- error(E_SIZES,"hhtrcols");
- if ( i0 > M->m || j0 > M->n )
- error(E_BOUNDS,"hhtrcols");
-
- if ( beta == 0.0 ) return (M);
-
- w = v_resize(w,M->n);
- MEM_STAT_REG(w,TYPE_VEC);
- v_zero(w);
-
- for ( i = i0; i < M->m; i++ )
- if ( hh->ve[i] != 0.0 )
- __mltadd__(&(w->ve[j0]),&(M->me[i][j0]),hh->ve[i],
- (int)(M->n-j0));
- for ( i = i0; i < M->m; i++ )
- if ( hh->ve[i] != 0.0 )
- __mltadd__(&(M->me[i][j0]),&(w->ve[j0]),-beta*hh->ve[i],
- (int)(M->n-j0));
- return (M);
- }
-
- FileDataŵinit Eÿÿÿè%@ Ðë
- /**************************************************************************
- **
- ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
- **
- ** Meschach Library
- **
- ** This Meschach Library is provided "as is" without any express
- ** or implied warranty of any kind with respect to this software.
- ** In particular the authors shall not be liable for any direct,
- ** indirect, special, incidental or consequential damages arising
- ** in any way from use of the software.
- **
- ** Everyone is granted permission to copy, modify and redistribute this
- ** Meschach Library, provided:
- ** 1. All copies contain this copyright notice.
- ** 2. All modified copies shall carry a notice stating who
- ** made the last modification and the date of such modification.
- ** 3. No charge is made for this software or works derived from it.
- ** This clause shall not be construed as constraining other software
- ** distributed on the same medium as this software, nor is a
- ** distribution fee considered a charge.
- **
- ***************************************************************************/
-
-
- /*
- This is a file of routines for zero-ing, and initialising
- vectors, matrices and permutations.
- This is to be included in the matrix.a library
- */
-
- static char rcsid[] = "$Id: init.c,v 1.6 1994/01/13 05:36:58 des Exp $";
-
- #include <stdio.h>
- #include "matrix.h"
-
- /* v_zero -- zero the vector x */
- VEC *v_zero(x)
- VEC *x;
- {
- if ( x == VNULL )
- error(E_NULL,"v_zero");
-
- __zero__(x->ve,x->dim);
- /* for ( i = 0; i < x->dim; i++ )
- x->ve[i] = 0.0; */
-
- return x;
- }
-
-
- /* iv_zero -- zero the vector ix */
- IVEC *iv_zero(ix)
- IVEC *ix;
- {
- int i;
-
- if ( ix == IVNULL )
- error(E_NULL,"iv_zero");
-
- for ( i = 0; i < ix->dim; i++ )
- ix->ive[i] = 0;
-
- return ix;
- }
-
-
- /* m_zero -- zero the matrix A */
- MAT *m_zero(A)
- MAT *A;
- {
- int i, A_m, A_n;
- Real **A_me;
-
- if ( A == MNULL )
- error(E_NULL,"m_zero");
-
- A_m = A->m; A_n = A->n; A_me = A->me;
- for ( i = 0; i < A_m; i++ )
- __zero__(A_me[i],A_n);
- /* for ( j = 0; j < A_n; j++ )
- A_me[i][j] = 0.0; */
-
- return A;
- }
-
- /* mat_id -- set A to being closest to identity matrix as possible
- -- i.e. A[i][j] == 1 if i == j and 0 otherwise */
- MAT *m_ident(A)
- MAT *A;
- {
- int i, size;
-
- if ( A == MNULL )
- error(E_NULL,"m_ident");
-
- m_zero(A);
- size = min(A->m,A->n);
- for ( i = 0; i < size; i++ )
- A->me[i][i] = 1.0;
-
- return A;
- }
-
- /* px_ident -- set px to identity permutation */
- PERM *px_ident(px)
- PERM *px;
- {
- int i, px_size;
- u_int *px_pe;
-
- if ( px == PNULL )
- error(E_NULL,"px_ident");
-
- px_size = px->size; px_pe = px->pe;
- for ( i = 0; i < px_size; i++ )
- px_pe[i] = i;
-
- return px;
- }
-
- /* Pseudo random number generator data structures */
- /* Knuth's lagged Fibonacci-based generator: See "Seminumerical Algorithms:
- The Art of Computer Programming" sections 3.2-3.3 */
-
- #ifdef ANSI_C
- #ifndef LONG_MAX
- #include <limits.h>
- #endif
- #endif
-
- #ifdef LONG_MAX
- #define MODULUS LONG_MAX
- #else
- #define MODULUS 1000000000L /* assuming long's at least 32 bits long */
- #endif
- #define MZ 0L
-
- static long mrand_list[56];
- static int started = FALSE;
- static int inext = 0, inextp = 31;
-
-
- /* mrand -- pseudo-random number generator */
- #ifdef ANSI_C
- double mrand(void)
- #else
- double mrand()
- #endif
- {
- long lval;
- static Real factor = 1.0/((Real)MODULUS);
-
- if ( ! started )
- smrand(3127);
-
- inext = (inext >= 54) ? 0 : inext+1;
- inextp = (inextp >= 54) ? 0 : inextp+1;
-
- lval = mrand_list[inext]-mrand_list[inextp];
- if ( lval < 0L )
- lval += MODULUS;
- mrand_list[inext] = lval;
-
- return (double)lval*factor;
- }
-
- /* mrandlist -- fills the array a[] with len random numbers */
- void mrandlist(a, len)
- Real a[];
- int len;
- {
- int i;
- long lval;
- static Real factor = 1.0/((Real)MODULUS);
-
- if ( ! started )
- smrand(3127);
-
- for ( i = 0; i < len; i++ )
- {
- inext = (inext >= 54) ? 0 : inext+1;
- inextp = (inextp >= 54) ? 0 : inextp+1;
-
- lval = mrand_list[inext]-mrand_list[inextp];
- if ( lval < 0L )
- lval += MODULUS;
- mrand_list[inext] = lval;
-
- a[i] = (Real)lval*factor;
- }
- }
-
-
- /* smrand -- set seed for mrand() */
- void smrand(seed)
- int seed;
- {
- int i;
-
- mrand_list[0] = (123413*seed) % MODULUS;
- for ( i = 1; i < 55; i++ )
- mrand_list[i] = (123413*mrand_list[i-1]) % MODULUS;
-
- started = TRUE;
-
- /* run mrand() through the list sufficient times to
- thoroughly randomise the array */
- for ( i = 0; i < 55*55; i++ )
- mrand();
- }
- #undef MODULUS
- #undef MZ
- #undef FAC
-
- /* v_rand -- initialises x to be a random vector, components
- independently & uniformly ditributed between 0 and 1 */
- VEC *v_rand(x)
- VEC *x;
- {
- /* int i; */
-
- if ( ! x )
- error(E_NULL,"v_rand");
-
- /* for ( i = 0; i < x->dim; i++ ) */
- /* x->ve[i] = rand()/((Real)MAX_RAND); */
- /* x->ve[i] = mrand(); */
- mrandlist(x->ve,x->dim);
-
- return x;
- }
-
- /* m_rand -- initialises A to be a random vector, components
- independently & uniformly distributed between 0 and 1 */
- MAT *m_rand(A)
- MAT *A;
- {
- int i /* , j */;
-
- if ( ! A )
- error(E_NULL,"m_rand");
-
- for ( i = 0; i < A->m; i++ )
- /* for ( j = 0; j < A->n; j++ ) */
- /* A->me[i][j] = rand()/((Real)MAX_RAND); */
- /* A->me[i][j] = mrand(); */
- mrandlist(A->me[i],A->n);
-
- return A;
- }
-
- /* v_ones -- fills x with one's */
- VEC *v_ones(x)
- VEC *x;
- {
- int i;
-
- if ( ! x )
- error(E_NULL,"v_ones");
-
- for ( i = 0; i < x->dim; i++ )
- x->ve[i] = 1.0;
-
- return x;
- }
-
- /* m_ones -- fills matrix with one's */
- MAT *m_ones(A)
- MAT *A;
- {
- int i, j;
-
- if ( ! A )
- error(E_NULL,"m_ones");
-
- for ( i = 0; i < A->m; i++ )
- for ( j = 0; j < A->n; j++ )
- A->me[i][j] = 1.0;
-
- return A;
- }
-
- /* v_count -- initialises x so that x->ve[i] == i */
- VEC *v_count(x)
- VEC *x;
- {
- int i;
-
- if ( ! x )
- error(E_NULL,"v_count");
-
- for ( i = 0; i < x->d printf("# det_mant1=%g, det_expt1=%d\n",
- det_mant1,det_expt1); */
- /* printf("# det_mant2=%g, det_expt2=%d\n",
- det_mant2,det_expt2); */
- if ( det_mant1 == 0.0 )
- { /* multiple e-val of T */
- err_est->ve[i] = 0.0;
- continue;
- }
- else if ( det_mant2 == 0.0 )
- {
- err_est->ve[i] = HUGE;
- continue;
- }
- if ( (det_expt1 + det_expt2) % 2 )
- /* if odd... */
- det_mant = sqrt(2.0*fabs(det_mant1*det_mant2));
- else /* if even... */
- det_mant = sqrt(fabs(det_mant1*det_mant2));
- det_expt = (det_expt1+det_expt2)/2;
- err_est->ve[i] = fabs(beta*
- ldexp(pb_mant/det_mant,pb_expt-det_expt));
- }
- }
-
- return a;
- }
-
- /* iter_splanczos2 -- version of iter_lanczos2() that uses sparse matrix data
- structure */
-
- VEC *iter_splanczos2(A,m,x0,evals,err_est)
- SPMAT *A;
- int m;
- VEC *x0; /* initial vector */
- VEC *evals; /* eigenvalue vector */
- VEC *err_est; /* error estimates of eigenvalues */
- {
- ITER *ip;
- VEC *a;
-
- ip = iter_get(0,0);
- ip->Ax = (Fun_Ax) sp_mv_mlt;
- ip->A_par = (void *) A;
- ip->x = x0;
- ip->k = m;
- a = iter_lanczos2(ip,evals,err_est);
- ip->shared_x = ip->shared_b = TRUE;
- iter_free(ip); /* release only ITER structure */
- return a;
- }
-
-
-
-
- /*
- Conjugate gradient method
- Another variant - mainly for testing
- */
-
- VEC *iter_cg1(ip)
- ITER *ip;
- {
- static VEC *r = VNULL, *p = VNULL, *q = VNULL, *z = VNULL;
- Real alpha;
- double inner,nres;
- VEC *rr; /* rr == r or rr == z */
-
- if (ip == INULL)
- error(E_NULL,"iter_cg");
- if (!ip->Ax || !ip->b)
- error(E_NULL,"iter_cg");
- if ( ip->x == ip->b )
- error(E_INSITU,"iter_cg");
- if (!ip->stop_crit)
- error(E_NULL,"iter_cg");
-
- if ( ip->eps <= 0.0 )
- ip->eps = MACHEPS;
-
- r = v_resize(r,ip->b->dim);
- p = v_resize(p,ip->b->dim);
- q = v_resize(q,ip->b->dim);
-
- MEM_STAT_REG(r,TYPE_VEC);
- MEM_STAT_REG(p,TYPE_VEC);
- MEM_STAT_REG(q,TYPE_VEC);
-
- if (ip->Bx != (Fun_Ax)NULL) {
- z = v_resize(z,ip->b->dim);
- MEM_STAT_REG(z,TYPE_VEC error(E_SIZES,"m_sub");
- if ( out==(MAT *)NULL || out->m != mat1->m || out->n != mat1->n )
- out = m_resize(out,mat1->m,mat1->n);
- m = mat1->m; n = mat1->n;
- for ( i=0; i<m; i++ )
- {
- __sub__(mat1->me[i],mat2->me[i],out->me[i],(int)n);
- /**************************************************
- for ( j=0; j<n; j++ )
- out->me[i][j] = mat1->me[i][j]-mat2->me[i][j];
- **************************************************/
- }
-
- return (out);
- }
-
- /* m_mlt -- matrix-m