Beispiel #1
0
 /* main5-3.c 检验bo5-3.c的主程序(与main5-2.c很相像) */
 #include"c1.h"
 typedef int ElemType;
 #include"c5-3.h" /* 此行与main5-2.c不同 */
 #include"bo5-3.c" /* 此行与main5-2.c不同 */
 void main()
 {
   RLSMatrix A,B,C; /* 此行与main5-2.c不同 */
   printf("创建矩阵A: ");
   CreateSMatrix(&A);
   PrintSMatrix(A);
   printf("由矩阵A复制矩阵B:\n");
   CopySMatrix(A,&B);
   PrintSMatrix1(B);
   DestroySMatrix(&B);
   printf("销毁矩阵B后:\n");
   PrintSMatrix1(B);
   printf("创建矩阵B2:(与矩阵A的行、列数相同,行、列分别为%d,%d)\n",A.mu,A.nu);
   CreateSMatrix(&B);
   PrintSMatrix1(B);
   AddSMatrix(A,B,&C);
   printf("矩阵C1(A+B):\n");
   PrintSMatrix1(C);
   SubtSMatrix(A,B,&C);
   printf("矩阵C2(A-B):\n");
   PrintSMatrix1(C);
   TransposeSMatrix(A,&C);
   printf("矩阵C3(A的转置):\n");
   PrintSMatrix1(C);
   printf("创建矩阵A2:");
   CreateSMatrix(&A);
   PrintSMatrix1(A);
   printf("创建矩阵B3:(行数应与矩阵A2的列数相同=%d)\n",A.nu);
   CreateSMatrix(&B);
   PrintSMatrix1(B);
   MultSMatrix(A,B,&C);
   printf("矩阵C5(A×B):\n");
   PrintSMatrix1(C);
 }
void main()
{
	CrossList a;
	Init(a);
	CreateSMatrix(a);
	print(a);
}
 void main()
 {
   CrossList A,B,C;
   InitSMatrix(A); // CrossList类型的变量在初次使用之前必须初始化
   InitSMatrix(B);
   printf("创建矩阵A: ");
   CreateSMatrix(A);
   PrintSMatrix(A);
   printf("由矩阵A复制矩阵B: ");
   CopySMatrix(A,B);
   PrintSMatrix(B);
   DestroySMatrix(B); // CrossList类型的变量在再次使用之前必须先销毁
   printf("销毁矩阵B后,矩阵B为:\n");
   PrintSMatrix1(B);
   printf("创建矩阵B2:(与矩阵A的行、列数相同,行、列分别为%d,%d)\n",A.mu,A.nu);
   CreateSMatrix(B);
   PrintSMatrix1(B);
   printf("矩阵C1(A+B):\n");
   AddSMatrix(A,B,C);
   PrintSMatrix1(C);
   DestroySMatrix(C);
   printf("矩阵C2(A-B):\n");
   SubtSMatrix(A,B,C);
   PrintSMatrix1(C);
   DestroySMatrix(C);
   printf("矩阵C3(A的转置):\n");
   TransposeSMatrix(A,C);
   PrintSMatrix1(C);
   DestroySMatrix(A);
   DestroySMatrix(B);
   DestroySMatrix(C);
   printf("创建矩阵A2: ");
   CreateSMatrix(A);
   PrintSMatrix1(A);
   printf("创建矩阵B3:(行数应与矩阵A2的列数相同=%d)\n",A.nu);
   CreateSMatrix(B);
   PrintSMatrix1(B);
   printf("矩阵C5(A×B):\n");
   MultSMatrix(A,B,C);
   PrintSMatrix1(C);
   DestroySMatrix(A);
   DestroySMatrix(B);
   DestroySMatrix(C);
 }
 void main()
 {
   TSMatrix A,B;
   printf("创建矩阵A: ");
   CreateSMatrix(A);
   PrintSMatrix1(A);
   FastTransposeSMatrix(A,B);
   printf("矩阵B(A的快速转置):\n");
   PrintSMatrix1(B);
 }
void main()
{
	TSMatrix A, B;
	printf("创建矩阵A: ");
	CreateSMatrix(&A);
	PrintSMatrix(A);
	FastTransposeSMatrix(A, &B);
	printf("矩阵B(A的快速转置): ");
	PrintSMatrix(B);
	DestroySMatrix(&A);
	DestroySMatrix(&B);
}
Beispiel #6
0
/* CloneSMatrix: return a clone of given Matrix */
SMatrix CloneSMatrix(MemHeap *hmem, SMatrix s, Boolean sharing)
{
   SMatrix t;  /* the target */

   if (s==NULL) return NULL;
   if (GetUse(s)>0 && sharing) {
      IncUse(s);
      return s;
   }
   t = CreateSMatrix(hmem,NumRows(s),NumCols(s));
   CopyMatrix(s,t);
   return t;
}