📄 mem.c
字号:
/* * -*- Mode: ANSI C -*- * $Id: mem.c,v 1.4 1996/09/17 16:10:51 fernande Exp $ * $Source: /sgi.acct/sweldens/cvs/liftpack/Util/mem.c,v $ * Author: Gabriel Fernandez * * Definition of vector-matrix utility functions needed by the * LU functions. *//* do not edit anything above this line *//* FLWT header files */#include <flwtdef.h>#include <flwterr.h>#include <mem.h>#include <memchk.h>/* allocate an integer vector with subscript range v[nl..nh] */int *ivector ( long nl, long nh ){ int *v; v=(int *) malloc((unsigned)(nh-nl+1)*sizeof(int)); if (!v) Error ("vector", MEMORY_VECTOR, ABORT); return v-nl;}/* allocate a f.p. vector with subscript range v[nl..nh] */Vector vector ( long nl, long nh ){ Vector v; v=(Vector) malloc((unsigned)(nh-nl+1)*sizeof(Flt)); if (!v) Error ("vector", MEMORY_VECTOR, ABORT); return v-nl;}/* allocate a f.p. matrix with subscript range m[nrl..nrh][ncl..nch] */Matrix matrix ( long nrl, long nrh, long ncl, long nch){ long i; Matrix m; /* allocate pointers to rows */ m=(Matrix) malloc((unsigned)(nrh-nrl+1)*sizeof(Vector)); if (!m) Error ("matrix", MEMORY_MATRIX, ABORT); m -= nrl; /* allocate rows and set pointers to them */ for ( i=nrl ; i<=nrh ; i++ ) { m[i] = (Vector) malloc((unsigned)(nch-ncl+1)*sizeof(Flt)); if (!m[i]) Error ("matrix", MEMORY_VECTOR, ABORT); m[i] -= ncl; } /* return pointer to array of pointers to rows */ return m;}/* free an integer vector allocated by vector() */void free_ivector ( int *v, long nl, long nh ){ free ((char*) (v+nl));}/* free a f.p. vector allocated by vector() */void free_vector ( Vector v, long nl, long nh ){ free ((char*) (v+nl));}/* free a f.p. matrix llocated by matrix() */void free_matrix ( Matrix m, long nrl, long nrh, long ncl, long nch ){ long i; for ( i=nrh ; i>=nrl ; i-- ) free ((char*) (m[i]+ncl)); free ((char*) (m+nrl));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -