#pragma once
#include"Vec_ZZ_p.h"
class Vec_ZZ_p;
#define ONE (unsigned char)1
#define TWO (unsigned char)2
#define THREE (unsigned char)3
#define SIX (unsigned char)6
class Mat_ZZ_p
{
public:
	Mat_ZZ_p(int row, int col);
	~Mat_ZZ_p(void);
	void resize(int i, int j);

	Mat_ZZ_p(const Mat_ZZ_p& other);
	Mat_ZZ_p&operator=(const Mat_ZZ_p&);
	int getRow()const;
	int getCol()const;
	void put(int i,int j,unsigned char a);
	unsigned char& elem(int i,int j);//引用返回的目的是返回值可以做左值
	unsigned char elem(int i,int j)const;

	friend Mat_ZZ_p operator+(const Mat_ZZ_p &,const Mat_ZZ_p &);
	friend Mat_ZZ_p operator-(const Mat_ZZ_p &,const Mat_ZZ_p &);
	Mat_ZZ_p& operator+=(const Mat_ZZ_p &a);
	Mat_ZZ_p& operator-=(const Mat_ZZ_p &a);

	friend Mat_ZZ_p operator*(int a,const Mat_ZZ_p& b);  //a * b
	friend Mat_ZZ_p operator*(const Mat_ZZ_p& b,int a); 
	friend Vec_ZZ_p operator*(const Mat_ZZ_p& b,const Vec_ZZ_p& a); //矩阵右乘一个向量

	void clear();
	friend std::ostream & operator<<(std::ostream &os,const Mat_ZZ_p& );
	bool SaveToTxt(const char *filename);//保存为文件
	bool LoadFromTxt(const char *filename);//从文件读取,读的时候要先设置好矩阵的维度

	friend int det(const Mat_ZZ_p &);
	friend Mat_ZZ_p inv(Mat_ZZ_p& A);
private:
	int Row;
	int Col;
	unsigned char *m;
};



