input-matrix1

来自「有限元程序」· 代码 · 共 100 行

TXT
100
字号
/*  ===================================================== *//*  MATRIX OEPRATION I                                    *//*                                                        *//*  Test basic matrix operations without units            *//*  ===================================================== */print "=========================================\n";print "*** Basic matrix operations without units\n";print "=========================================\n\n";/* [a] BUILT MATRIX */print "\n";print "================================================= \n";print "*** Define and print matrices using PrintMatrix() \n";print "================================================= \n\n";X = [1, 2, 3];Y = [1; 2; 3];Z = [1, 3; 2, 3];V = [1; 2; 3     ;4;      5; 6];W = [1, 2, 3     ,4,      5     ,6];PrintMatrix(V, W);print "\n";print "*** Get Dimensions of a matrix \n\n";size = Dimension(Z);print "*** Size of Matrix [Z]: \n";PrintMatrix(size);print "\n";print "===================================================== \n";print "*** Define and print matrices using PrintMatrixCast() \n";print "***                                                   \n";print "*** Syntax : PrintMatrixCast(X)                       \n";print "***                                                   \n";print "===================================================== \n\n";PrintMatrix(X);PrintMatrixCast(X);print "\n";print "=======================================================\n";print "*** Demonstrate Builtin Functions for Matrix Allocation\n";print "=======================================================\n\n";print "*** [a] : Allocate a 2 by 3 matrix\n";W = Matrix([2, 3]);print "*** [b] : Allocate a 1 by 3 matrix full of zeros \n";X = Zero([1, 3]);PrintMatrix(X);print "\n";print "*** [c] : Allocate a 3 by 3 matrix full of zeros \n";X = Zero([3, 3]);Y = Zero([3]);PrintMatrix(X, Y);print "\n";print "*** [d] : Allocate a matrix full of zeros, the size is same of [W] \n";X = Zero(Dimension(W));PrintMatrix(X);print "\n";print "*** [e] : Allocate a 3 by 3 matrix full of ones\n";X = One([3, 3]);Y = One([3]);PrintMatrix(X, Y);print "\n";print "*** [f] : Allocate a 3 by 3 diagonal matrix with 2 at diagonal \n";print "          and a 4 by 4 identity matrix \n";X = Diag([3, 2]);Y = Diag([4, 1]);PrintMatrix(X, Y);print "\n";print "=====================================================\n";print "*** End Test on basic matrix operations without units\n";print "=====================================================\n";quit;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?