⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.h

📁 一个矩阵类
💻 H
字号:

#ifndef MATRIX_H
#define MATRIX_H
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream.h>

class matrix
{public:
 ///
 ///   构造和析构函数
 matrix();
 matrix(int n,int m);  //指定行列构造函数
 matrix(int n,int m,double value[]); // 指定数据构造函数
 matrix(int nn,double value[]);    //方阵构造函数
 matrix(matrix &other);  //赋值构造函数
 ~matrix();
 ///
 ///   元素与值的操作
 bool setElement(int n,int m,double value);
 void setdate(double value[]);
 double getElement(int n,int m)  const;
 int getRow();
 int getColumn();
 int getRowVector(int n,double *pvector); //获取某一行的值
 int getColumnVector(int n,double *pvector);//获取某一列的值
 double *getdate() const; // 获取矩阵里所有数据
 void  print(); //屏幕输出矩阵
 ////
 ////    矩阵的数学操作    
 ////
 matrix &operator=(matrix &other) ; ///矩阵给矩阵赋值
 bool operator==(matrix &other) const;// 比较两个矩阵的值是否相等,若相等返回:真1,否则返回:假0
 matrix operator+(matrix &other);    ////两个矩阵相加
 matrix operator-(matrix &other);   ////两个矩阵相减
 matrix operator*(matrix &other);   ///两个矩阵相乘
 matrix operator*(double k);
 matrix operator/(double k);
 ////
 bool init(int n,int m);  // 矩阵初始化; n 表示行数,m 表示列数
 protected:
 int column;    // 矩阵列数
 int row;       // 矩阵行数
 double *pdate; // 矩阵数据
};
#endif 

⌨️ 快捷键说明

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