matdemo3.cpp
来自「一个方便进行矩阵运算的C++函数包」· C++ 代码 · 共 70 行
CPP
70 行
//////////////////////////////////////////////////////
// File: MatDemo3.cpp
// Purpose: Demonstrates use of matrix template class
// Author: Somnath Kundu
#include "matrix.h"
#ifndef _NO_NAMESPACE
using namespace std;
using namespace math;
#define STD std
#else
#define STD
#endif
#ifndef _NO_EXCEPTION
# define TRYBEGIN try {
# define CATCHERROR } catch (const STD::exception e) { \
cout << "Error: " << e.what() << endl; }
#else
# define TRYBEGIN
# define CATCHERROR
#endif
typedef matrix<double> Matrix;
int main ()
{
Matrix m(3,3);
TRYBEGIN
cout << "Enter a matrix of (3X3) order:\n";
cin >> m;
cout << "This is a ";
if (m.IsSquare())
cout << "Square ";
if (m.IsSingular())
cout << "Singular ";
if (m.IsDiagonal())
cout << "Diagonal ";
if (m.IsUnit())
cout << "Unit ";
if (m.IsNull())
cout << "Null ";
if (m.IsSymmetric())
cout << "Symmetric ";
if (m.IsSkewSymmetric())
cout << "SkewSymmetric ";
if (m.IsUpperTiangular())
cout << "UpperTiangular ";
if (m.IsLowerTiangular())
cout << "LowerTiangular ";
if (m.IsScalar())
cout << "Scaler ";
CATCHERROR
cout << "matrix.\n";
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?