extern double *mat(int n, int m)
1、n<=0 or m>=0 return NULL
2、内存分配错误 !(p=(double *)malloc(sizeof(double)*n*m))
fatalerr("matrix memory allocation error: n=%d,m=%d\n",n,m);
extern int *imat(int n, int m)
1、n<=0 or m>=0 return NULL
2、内存分配错误 !(p=(int *)malloc(sizeof(int)*n*m))
fatalerr("integer matrix memory allocation error: n=%d,m=%d\n",n,m);
extern double *zeros(int n, int m)
#if #else #endif 预处理命令
NOCALLOC if ((p=mat(n,m))) for (n=n*m-1;n>=0;n--) p[n]=0.0;
#else
1、 n<=0 or m>=0 return NULL
2、内存分配错误 !(p=(double *)malloc(sizeof(int)*n*m))
fatalerr("matrix memory allocation error: n=%d,m=%d\n",n,m);
extern double *eye(int n)
if ((p=zeros(n,n))) for (i=0;i
eg. n=0,则p[0]=p[3]=1.0
extern void matcpy(double *A, const double *B, int n, int m)
{
memcpy(A,B,sizeof(double)*n*m);
}
void *memcpy(void *str1, const void *str2, size_t n) 从存储区 str2 复制 n 个字节到存储区 str1。
extern double dot(const double *a, const double *b, int n)
extern double norm(const double *a, int n)
内积开根号 a的模 |a|=(a[0]^2+a[1]^2+a[2]^2+)^(1/2)
extern void cross3(const double *a, const double *b, double *c)
extern int normv3(const double *a, double *b)
若 |a|<=0, return 0。
单位矢量为b =[a[0]/|a|,a[1]/|a|,a[2]/|a|,]