亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tmatrix.h

?? 是一個matrix類
?? H
?? 第 1 頁 / 共 3 頁
字號:
/********************************************************************************
CopyRight: You can use the Class freely as long as you keep this comment and the following :
Authour: Warren Wo ,HangZhou ZheJiang province;
Email: woyf@sina.com
QQ:124254045
*************************************************************************/
//---------------------------------------------------------------------------

#ifndef TMATRIX_H_
#define TMATRIX_H_

//container and iterator:
#include <vector>
#include <valarray>
#include <algorithm>
#include <functional>
//i/o operations:
#include <fstream.h>
//special classes:
#include <complex>
#include <numeric>
#pragma hdrstop
#define CERR(S)    {cerr<<S<<endl; getch();throw;}

using namespace std;

//---------------------------------------------------------------------------
typedef complex<double> complex_double_type;

template<class type = complex_double_type>          //defaul type: complex<double>

class matrix{
private:
     //Matrix:
    typedef type Cell;                              //cells
    typedef vector<Cell> RowVector;                 //row vectors
    typedef vector<Cell> ColVector;                 //column vectors
    typedef vector<RowVector> Matrix_type;          //matrix set up by row vectors

    //Only used in some member functions such as CreatMatrix() , operator =()...
    //to estimate if there are enough memories or if the rowCount or colCount
    //is validate:
    RowVector rVector;
    ColVector cVector;

    //"Mother" vectors whose elements are also vectors;:
    Matrix_type Matrix;

     int rowSize,rowCount;               //Size of a row and row count:
    //rowSize == colCount, colSize == rowCount
     int& colSize;                       //column size
     int& colCount;                     //the number of columns
     int totalElem;                     //total number of element in the matrix

    bool inline CreatMatrix();              //Creat Matrix frame

public:
    //Constructors:
    matrix():colSize(rowCount),colCount(rowSize){}
    //matrix with dimension m*n
    matrix( int RowCount , int ColCount );
    //Initialize matrix by using unary dim array:
    matrix(const type A[],const int& ArraySize,int RowCount , int ColCount);
    //copy constructor:
    matrix(const matrix<type>&);

    //destructor:
    ~matrix(){ }

    //"=" operator:
    //Reminder: the type of the left and the right must be the same.For example:
    //the following is legal: matrix<complex<int>> m1; matrix <complex<int>> m2; m1 = m2;
    //while it's invalidate if "m1" turn to be "matrix<int>" type:
    matrix<type>& operator = (const matrix<type>& M);

    //uniary operators:

    //"!" operator: the inverse of matrix:
     matrix<complex_double_type> operator !();
    //"~" operator: to turn a matrix:
     matrix<type> operator~();
     //"^" Operator: matrix pow:
     matrix<type> operator ^(const int);
     //Binary operators:
    //+= operator:
     matrix<type>& operator +=(const matrix<type>&);
    //-= operator:
     matrix<type>& operator -=(const matrix<type>&);
    //*= operator:
     matrix<type>& operator *=(const matrix<type>&);
     matrix<type>& operator *=(const type&);
     //"==" and "!=" operators:
     bool operator ==(const matrix<type>&);
     bool operator !=(const matrix<type>&);
     //reference
     const vector<type> operator[ ](const int&) const;
    void adjust(const int&,const int&);
    //Load Matrix from a file
    void LoadFromFile(const char*filename,ios_base::openmode mode = ios_base::in);
    //Set an element,a single row or column:
    void SetCells( int rIndex, int cIndex,const Cell& cell);
    void SetRows( int rIndex, vector<type>& RowVector);
    void SetCols( int cIndex, vector<type>& ColVector);

    //Save Matrix to a file
    void SaveToFile
    (const char* filename,ios_base::openmode mode = ios_base::out);
    //Read a row/column indicated by the parament:
    const RowVector ReadRows( int RowIndex) const;
    const ColVector ReadCols( int ColIndex) const;
    //Read a element mantained by the matrix:
    const Cell ReadCells( int rIndex, int cIndex) const;
    //Return row/column count:
    const  int inline RowCount() const;
    const  int inline ColCount() const;
    //Swap rows/columns:
    void SwapRows( int rowIndex1,  int rowIndex2);
    void SwapCols( int colIndex1,  int colIndex2);
    //Add a new row/column at the end:
    void AddRow(const vector<type>& Vector);
    void AddCol(const vector<type>& Vector);
    //Resize the matrix:
    void resize(const int RowCount, const int ColCount,const Cell& cell = 0 );
    //Get associate matrix:
    matrix<type>& associate();
    //Apply function to rows/cols:
    void ApplyRows(const int RowIndex,type fun(type&));
    void ApplyCols(const int ColIndex,type fun(type&));
    //Shirnk this matrix to indentity matrix which has the dims of the samller of the row count
    //and column count:
    void ShrinkToIdentityMatrix();
    //convert matrix to complex double type:
    matrix<complex_double_type> c_complex_double();
    //convert matrix to double type:
    matrix<double> c_double();
};

//#define DEBUG
//---------------------------------------------------------------------------
//**********************************************
// non-inline member functions definition:
//**********************************************
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
//*******************************
//Private member functions:
//*******************************
//---------------------------------------------------------------------------

template<class type>bool
inline matrix<type>::CreatMatrix()
{
    //creat failed if there are not enough memory:
    if(rowSize > rVector.max_size() || colSize > cVector.max_size())
        return 0;
    else{
         //creat subvectors in the matrix:
        vector<type> rowVector(rowSize);
        //creat mother vectors
        Matrix.resize(rowCount);
        //Link subvectors with the mother vector to creat the frame:
        fill(Matrix.begin(),Matrix.end(),rowVector);
    return true;
    }
}

//---------------------------------------------------------------------------
//*******************************
//public member functions:
//*******************************
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
//Constructors:
//---------------------------------------------------------------------------

template<class type>
matrix<type>:: matrix( int RowCount , int ColCount):
    rowCount(RowCount),rowSize(ColCount),colSize(rowCount),colCount(rowSize)
{
    //ensure row count and column count at least no less than 1;
    rowCount =( rowCount>0 ) ? rowCount : 1;
    rowSize = ( rowSize >0 ) ? rowSize  : 1;

   totalElem = rowCount * rowSize;
    //Creat matrix frame:
    if(!CreatMatrix())
        throw;

}
//Constructor: to convert an unary array to matrix:
template<class type>
matrix<type>:: matrix(const type A[],const int& ArraySize,int RowCount,int ColCount):
    rowCount(RowCount),rowSize(ColCount),colSize(rowCount),colCount(rowSize)
{
     //ensure row count and column count at least no less than 1;
    rowCount =( rowCount>0 ) ? rowCount : 1;
    rowSize = ( rowSize >0 ) ? rowSize  : 1;

   totalElem = rowCount * rowSize;
    //Creat matrix frame:
    if(!CreatMatrix())
        throw;
    int u = 0;
    for(int i=0;i<rowCount;i++){
        for(int j =0;j<colCount && u < ArraySize;j++,u++)
        Matrix[i][j] = A[u];
    }
}

//Copy constructor:
template<class type>
matrix<type>:: matrix(const matrix<type>& M):colSize(rowCount),colCount(rowSize)  //ini reference member:
{
    Matrix.resize(M.RowCount());
    for(int i = 0;i < M.RowCount() ;i++){
        Matrix[i] = M.ReadRows(i);
    }
    rowCount = Matrix.size();
    colCount = Matrix[0].size();

}
//---------------------------------------------------------------------------
//: "=" operator:
//---------------------------------------------------------------------------
template<class type> matrix<type>&
matrix<type>::operator = (const matrix<type>& M)
{
    const int safeFactor = 10000;       //keep rowCount or colCount less than 10000;
    //self-assignment testing:
    if(this == &M) return *this;

    if(M.RowCount() > safeFactor){
        CERR("Requiring too many rows or columns! Member function operator=()\
            failed.Any key to quit.");
     }
    Matrix.resize(M.RowCount());
    for(int i = 0;i < M.RowCount() ;i++){
        Matrix[i] = M.ReadRows(i);
    }
    rowCount = Matrix.size();
    colCount = Matrix[0].size();
    return *this;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//Common member functions:
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

template<class type> void
matrix<type>::SetCells( int rIndex, int cIndex,const Cell& cell)
{
     if( cIndex >= colCount || rIndex >= rowCount || rIndex < 0 || cIndex < 0){
        CERR("No cell can be set!Any key to Quit.");
     }
    const  int i = rIndex,j = cIndex;
    Matrix[i][j] = cell;

}
//---------------------------------------------------------------------------
template<class type> const type
matrix<type>::ReadCells( int rIndex, int cIndex) const
{
  if( cIndex >= colCount || rIndex >= rowCount || rIndex < 0 || cIndex < 0){
        CERR("This cell doesn't exit!Any key to Quit.");

     }
  const  int i = rIndex,j = cIndex;
  return  Matrix[i][j];
}

//---------------------------------------------------------------------------
template<class type>void
matrix<type>::LoadFromFile(const char* filename,ios_base::openmode mode)
{

    //Open file to input:
    ifstream matrixIn(filename,mode | ios::nocreate);
    if(!matrixIn){
       CERR("File don't exit!LoadFromFile() failed.Any key to Quit.");
        }

    istream_iterator<type,char>  infstream(matrixIn),eof;

    vector<type> rowVector(totalElem);
    //temp vector that recieve all elements from input file:
    vector<Cell> tempVect;
    copy(infstream,eof,inserter(tempVect,tempVect.begin()));

    //Copy temp vector to rowVector,and now it is safe even if the number of elements
    //in the file is more than that of the matrix.By using block,it's also safe when
    //the number of elemnets in the file is less than the matrix's size. The matrix
    //will just get as many as it can mantain from the begining of the file to the
    //NO. totalElem.

     int block;
    block = (totalElem > tempVect.size()) ? tempVect.size() : totalElem;

    copy(tempVect.begin(),tempVect.begin() + block,rowVector.begin());

    //Store cells to the Matrix:
    vector<Cell>::iterator location = rowVector.begin();
     for(int i = 0;i < rowCount ;i++){
             //copy to matrix set up by row:

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲chinese男男1069| 一区二区三区四区蜜桃| 亚洲电影中文字幕在线观看| 国产成人精品aa毛片| 欧美伦理视频网站| 国产精品短视频| 久久精品国产成人一区二区三区 | 日韩理论片在线| 国产在线播放一区| 91精品国产综合久久福利| 亚洲欧美电影院| 久久久99免费| 九九**精品视频免费播放| 欧美色精品在线视频| 国产精品久久看| 国产一区不卡精品| 欧美v日韩v国产v| 日本在线不卡视频| 欧美天堂一区二区三区| 亚洲欧美一区二区三区久本道91 | 久久国产精品99精品国产| 欧美日韩一区在线| 亚洲另类在线视频| 不卡大黄网站免费看| 国产日韩欧美电影| 精品一区二区成人精品| 538在线一区二区精品国产| 洋洋成人永久网站入口| 91亚洲精品一区二区乱码| 国产人妖乱国产精品人妖| 黄色精品一二区| 精品91自产拍在线观看一区| 免费视频最近日韩| 91精品午夜视频| 日韩激情一区二区| 宅男噜噜噜66一区二区66| 香蕉久久夜色精品国产使用方法 | 欧美在线三级电影| 一区二区久久久| 欧美在线短视频| 亚洲制服丝袜av| 欧美三级中文字| 亚洲国产婷婷综合在线精品| 欧美日韩中字一区| 日韩av电影天堂| 日韩精品最新网址| 韩国女主播成人在线观看| 欧美成人精品3d动漫h| 久久精品99国产精品| 久久综合久久久久88| 国产最新精品精品你懂的| 久久综合久久综合亚洲| 国产suv精品一区二区三区| 日本一区二区三区视频视频| www.欧美日韩| 一区2区3区在线看| 欧美日韩国产中文| 美腿丝袜亚洲三区| 麻豆精品视频在线观看| 精品久久国产字幕高潮| 国产精品一区二区久激情瑜伽| 日本一区二区三区dvd视频在线| 成人白浆超碰人人人人| 亚洲精品视频在线| 7777女厕盗摄久久久| 久久激情五月婷婷| 国产日产精品一区| 日本电影欧美片| 人人超碰91尤物精品国产| 欧美精品一区二区高清在线观看| 国产99久久久久久免费看农村| 综合av第一页| 欧美一级在线视频| 国产高清不卡二三区| 亚洲精品国产无套在线观| 欧美高清视频一二三区| 国产一区二区精品久久91| 成人免费在线观看入口| 欧美日韩国产综合一区二区三区| 韩国欧美国产1区| 亚洲婷婷在线视频| 日韩一级大片在线| 成人午夜视频在线观看| 亚洲狠狠爱一区二区三区| 欧美成人vr18sexvr| 成人午夜av电影| 午夜精品成人在线视频| 国产亚洲美州欧州综合国| 在线中文字幕一区| 国产在线视视频有精品| 亚洲欧美韩国综合色| 日韩欧美一卡二卡| 91色porny在线视频| 美女视频黄 久久| 亚洲欧洲日本在线| 日韩视频在线一区二区| 91丝袜美腿高跟国产极品老师 | 中文一区二区完整视频在线观看| 日本电影欧美片| 国产精品中文字幕欧美| 亚洲一区二区三区四区五区黄| 久久免费偷拍视频| 欧美日韩国产一级| 成人av资源站| 九色综合国产一区二区三区| 一区二区三区在线看| 国产伦精品一区二区三区免费迷 | 三级久久三级久久久| 中日韩av电影| 欧美电视剧在线看免费| 色呦呦国产精品| 国产福利电影一区二区三区| 亚洲成人一区二区| 中文字幕在线不卡一区二区三区| 日韩一区国产二区欧美三区| 在线视频欧美区| www.亚洲色图| 国产精品中文字幕日韩精品| 日精品一区二区三区| 亚洲蜜桃精久久久久久久| 久久精品欧美一区二区三区麻豆 | 成熟亚洲日本毛茸茸凸凹| 日韩精品高清不卡| 亚洲综合免费观看高清完整版| 中文字幕欧美日本乱码一线二线| 日韩免费视频一区二区| 欧美日韩中文字幕一区| 色综合久久久网| 成人高清视频在线观看| 国产一区二区三区视频在线播放| 午夜激情一区二区| 一个色综合网站| 91麻豆福利精品推荐| 国产精品一区在线| 久久电影网站中文字幕| 日韩精品视频网| 婷婷久久综合九色综合伊人色| 一区二区三区日韩精品| 1区2区3区欧美| 国产精品久久久久久久午夜片| 欧美电影免费观看高清完整版 | 99久久99久久综合| 粉嫩久久99精品久久久久久夜 | 亚洲综合精品自拍| 亚洲精品视频一区| 亚洲免费电影在线| 亚洲精品视频自拍| 伊人婷婷欧美激情| 亚洲男人的天堂av| 亚洲乱码国产乱码精品精的特点 | 中文字幕不卡一区| 国产欧美日韩另类视频免费观看| 久久久久久久久97黄色工厂| 精品久久久久久无| 精品国产乱码久久久久久闺蜜 | 欧美亚洲另类激情小说| 欧美最猛性xxxxx直播| 在线欧美小视频| 欧美色综合网站| 欧美日韩亚洲综合一区二区三区| 欧美在线999| 无吗不卡中文字幕| 日本麻豆一区二区三区视频| 日本色综合中文字幕| 麻豆精品国产91久久久久久| 久草这里只有精品视频| 国产剧情在线观看一区二区| 国产一区二区三区黄视频| 国产精品一区二区无线| 成人午夜免费电影| 91小视频在线观看| 在线国产电影不卡| 欧美老肥妇做.爰bbww视频| 91精品国产麻豆| 久久这里都是精品| 国产精品久久久久一区二区三区共| 国产精品久久久久久久第一福利| 亚洲天堂av老司机| 亚洲高清免费一级二级三级| 日韩成人免费在线| 国产一区二区伦理片| av在线不卡免费看| 欧美性猛交一区二区三区精品| 欧美精品久久一区二区三区| 精品日本一线二线三线不卡| 国产欧美一区二区精品秋霞影院| 最新日韩av在线| 婷婷开心激情综合| 国产精品一二一区| 色综合网站在线| 91.com视频| 欧美激情在线看| 一区二区三区91| 精品一区二区精品| 99久久精品国产一区二区三区| 欧美日韩视频在线观看一区二区三区| 日韩亚洲国产中文字幕欧美| 国产视频一区在线播放| 亚洲精品国久久99热| 蜜桃久久精品一区二区|