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

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

?? matrixwithtranspose.h

?? datastucutre and algorithms, application, in C
?? H
字號:
// transpose method has been included
#ifndef matrix_
#define matrix_

#include "myExceptions.h"

using namespace std;
template<class T>
class matrix 
{
   friend ostream& operator<<(ostream&, const matrix<T>&);
   public:
      matrix(int theRows = 0, int theColumns = 0);
      matrix(const matrix<T>&);
      ~matrix() {delete [] element;}
      int rows() const {return theRows;}
      int columns() const {return theColumns;}
      T& operator()(int i, int j) const;
      matrix<T>& operator=(const matrix<T>&);
      matrix<T> operator+() const; // unary +
      matrix<T> operator+(const matrix<T>&) const;
      matrix<T> operator-() const; // unary minus
      matrix<T> operator-(const matrix<T>&) const;
      matrix<T> operator*(const matrix<T>&) const;
      matrix<T>& operator+=(const T&);
      void transpose(matrix<T>& b);
   private:
       int theRows,    // number of rows in matrix
           theColumns; // number of columns in matrix
       T *element;     // element array
};  

template<class T>
matrix<T>::matrix(int theRows, int theColumns)
{// matrix constructor.
   // validate theRows and theColumns
   if (theRows < 0 || theColumns < 0)
      throw illegalParameterValue("Rows and columns must be >= 0");
   if ((theRows == 0 || theColumns == 0)
                && (theRows != 0 || theColumns != 0))
      throw illegalParameterValue
      ("Either both or neither rows and columns should be zero");

   // create the matrix
   this->theRows = theRows;
   this->theColumns = theColumns;
   element = new T [theRows * theColumns];
}

template<class T>
matrix<T>::matrix(const matrix<T>& m)
{// Copy constructor for matrices.
   // create matrix
   theRows = m.theRows;
   theColumns = m.theColumns;
   element = new T [theRows * theColumns];

   // copy each element of m
   copy(m.element,
        m.element + theRows * theColumns,
        element);
}

template<class T>
matrix<T>& matrix<T>::operator=(const matrix<T>& m)
{// Assignment. (*this) = m.
   if (this != &m)
   {// not copying to self
      delete [] element;
      theRows = m.theRows;
      theColumns = m.theColumns;
      element = new T [theRows * theColumns];
      // copy each element
      copy(m.element,
           m.element + theRows * theColumns,
           element);
   }
   return *this;
}

template<class T>
T& matrix<T>::operator()(int i, int j) const
{// Return a reference to element (i,j).
   if (i < 1 || i > theRows
       || j < 1 || j > theColumns)
   throw matrixIndexOutOfBounds();
   return element[(i - 1) * theColumns + j - 1];
}

template<class T>
matrix<T> matrix<T>::
          operator+(const matrix<T>& m) const
{// Return w = (*this) + m.
   if (theRows != m.theRows
       || theColumns != m.theColumns)
      throw matrixSizeMismatch();

   // create result matrix w
   matrix<T> w(theRows, theColumns);
   for (int i = 0; i < theRows * theColumns; i++)
      w.element[i] = element[i] + m.element[i];

   return w;
}

template<class T>
matrix<T> matrix<T>::
          operator-(const matrix<T>& m) const
{// Return (*this) - m.
   if (theRows != m.theRows 
       || theColumns != m.theColumns)
      throw matrixSizeMismatch();

   // create result matrix w
   matrix<T> w(theRows, theColumns);
   for (int i = 0; i < theRows * theColumns; i++)
      w.element[i] = element[i] - m.element[i];

   return w;
}

template<class T>
matrix<T> matrix<T>::operator-() const
{// Return w = -(*this).

   // create result matrix w
   matrix<T> w(theRows, theColumns);
   for (int i = 0; i < theRows * theColumns; i++)
      w.element[i] = -element[i];
   return w;

}

template<class T>
matrix<T> matrix<T>::
          operator*(const matrix<T>& m) const
{// matrix multiply.  Return w = (*this) * m.
   if (theColumns != m.theRows) 
      throw matrixSizeMismatch();

   matrix<T> w(theRows, m.theColumns);  // result matrix

   // define cursors for *this, m, and w
   // and initialize to location of (1,1) element
   int ct = 0, cm = 0, cw = 0;

   // compute w(i,j) for all i and j
   for (int i = 1; i <= theRows; i++)
   {// compute row i of result
      for (int j = 1; j <= m.theColumns; j++)
      { // compute first term of w(i,j)
          T sum =  element[ct] * m.element[cm];

          // add in remaining terms
          for (int k = 2; k <= theColumns; k++)
          {
             ct++;  // next term in row i of *this
             cm += m.theColumns;  // next in column j of m
             sum += element[ct] * m.element[cm];
          }
          w.element[cw++] = sum;  // save w(i,j)
 
          // reset to start of row and next column
          ct -= theColumns - 1;
          cm = j;
      }

      // reset to start of next row and first column
      ct += theColumns;
      cm = 0;
   }

   return w;
}

template<class T>
matrix<T>& matrix<T>::operator+=(const T& x)
{// Increment all elements of *this by x.
   for (int i = 0; i < theRows * theColumns; i++)
       element[i] += x;
   return *this;
}

template<class T>
ostream& operator<<(ostream& out, const matrix<T>& m)
{// Put matrix m into the stream out.
 // One row per line.
   int k = 0;  // index into element array
   for (int i = 0; i < m.theRows; i++)
   {// do row i
      for (int j = 0; j < m.theColumns; j++)
         out << m.element[k++] << "  ";

      // row i finished
      out << endl;
   }

   return out;
}

// for some reason compiler can't create this on its own
ostream& operator<<(ostream& out, const matrix<int>& m)
{// Put matrix m into the stream out.
 // One row per line.
   int k = 0;  // index into element array
   for (int i = 0; i < m.theRows; i++)
   {// do row i
      for (int j = 0; j < m.theColumns; j++)
         out << m.element[k++] << "  ";

      // row i finished
      out << endl;
   }

   return out;
}

template<class T>
void matrix<T>::transpose(matrix<T>& b)
{// Set b to be the transpose of *this.
   // create result matrix
   b.theRows = theColumns;
   b.theColumns = theRows;
   delete [] b.element;
   b.element = new T [theRows * theColumns];

   // copy from this->element to b.element
   int ct = 0;  // next element to move into the transpose
   for (int i = 1; i <= theRows; i++)
      for (int j = 1; j <= theColumns; j++)
         b.element[(j - 1) * theRows + i - 1] = element[ct++];

}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人天堂资源www在线| 亚洲女与黑人做爰| 欧美精品99久久久**| 日本乱人伦aⅴ精品| 国产sm精品调教视频网站| 久久精品国产99国产| 久久精品国产99| 激情综合一区二区三区| 国产成人午夜片在线观看高清观看| 麻豆91精品视频| 国产91在线看| 91网站在线播放| 欧美在线观看视频一区二区三区 | 欧美日韩亚洲综合在线 | 欧美大片一区二区| 久久久久国产成人精品亚洲午夜| 精品精品欲导航| 久久免费看少妇高潮| 国产欧美日韩精品a在线观看| 中文字幕精品在线不卡| 亚洲欧洲综合另类| 亚洲电影第三页| 国精产品一区一区三区mba视频| 国产成人精品影院| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | av中文字幕在线不卡| 99re视频精品| 欧美军同video69gay| 久久久亚洲国产美女国产盗摄| 日本一二三四高清不卡| 亚洲一级电影视频| 精品一区二区三区视频| 91网站在线播放| 日韩一区二区三区视频| 国产日韩欧美亚洲| 亚洲成人av一区二区| 国产伦精品一区二区三区免费迷 | 91美女视频网站| 欧美一区永久视频免费观看| 久久久久久久久久久久久女国产乱| 国产精品不卡在线| 日本在线不卡一区| av网站免费线看精品| 日韩精品中文字幕一区| 最新热久久免费视频| 六月丁香婷婷色狠狠久久| 色婷婷久久久综合中文字幕 | 国产精品久线观看视频| 日韩精品电影一区亚洲| 99视频在线观看一区三区| 欧美一级黄色录像| 亚洲主播在线观看| 成人app网站| 精品乱人伦小说| 午夜不卡在线视频| 色婷婷亚洲婷婷| 国产精品福利一区二区三区| 麻豆freexxxx性91精品| 欧美吞精做爰啪啪高潮| 1000部国产精品成人观看| 国内一区二区在线| 日韩一级成人av| 五月天亚洲精品| 欧美亚洲国产怡红院影院| 成人欧美一区二区三区在线播放| 国产一区二区三区最好精华液| 91麻豆精品国产91久久久更新时间| 亚洲欧洲制服丝袜| 成人黄色网址在线观看| 久久精品一区蜜桃臀影院| 九九热在线视频观看这里只有精品| 欧美日韩一区二区电影| 亚洲一区在线视频| 欧美在线综合视频| 亚洲国产视频a| 在线看国产日韩| 亚洲午夜久久久| 欧美亚洲精品一区| 肉色丝袜一区二区| 91精品国产综合久久久久| 丝袜美腿一区二区三区| 91麻豆精品国产自产在线| 日韩国产精品91| 日韩欧美一二三区| 韩国av一区二区| 欧美国产精品久久| 99vv1com这只有精品| 一区二区三区四区激情 | 日韩不卡一区二区| 欧美电视剧免费全集观看| 久久69国产一区二区蜜臀| 久久精品一区二区三区av| 国产成人亚洲综合色影视| 国产精品久久久久一区二区三区 | 日韩欧美成人激情| 国产一区二区精品在线观看| 国产精品五月天| 色狠狠综合天天综合综合| 亚洲成精国产精品女| 日韩一级片在线观看| 国产乱码精品1区2区3区| 成人欧美一区二区三区1314| 一本色道亚洲精品aⅴ| 婷婷久久综合九色国产成人| 精品播放一区二区| 波多野结衣中文字幕一区二区三区| 亚洲人成电影网站色mp4| 91精品国产一区二区三区蜜臀| 国产精品资源在线| 一区二区三区日韩欧美| 中文天堂在线一区| 欧美色中文字幕| 风流少妇一区二区| 午夜精品国产更新| 欧美国产一区二区在线观看| 欧美日韩在线电影| 国产suv精品一区二区三区| 午夜视黄欧洲亚洲| 自拍偷拍欧美激情| 欧美电影免费观看高清完整版在线| av不卡一区二区三区| 久久国产精品99久久久久久老狼 | 日韩国产一区二| 国产精品日韩精品欧美在线| 91精品国产综合久久久久| 色综合中文字幕国产| 日本va欧美va瓶| 亚洲综合图片区| 国产精品情趣视频| 精品国产一区久久| 制服丝袜日韩国产| 欧美亚洲精品一区| www.成人在线| 国产成人av影院| 久久精工是国产品牌吗| 视频一区欧美日韩| 亚洲一区二区视频在线观看| 国产精品高潮久久久久无| 久久婷婷成人综合色| 日韩精品一区二区三区在线| 欧美日韩精品一区二区三区| 一本大道久久a久久综合婷婷| 国产suv精品一区二区883| 激情综合网天天干| 精品一区二区免费在线观看| 蜜桃av一区二区| 美女视频一区在线观看| 日韩精品每日更新| 日本美女一区二区三区视频| 亚洲大片一区二区三区| 亚洲一区欧美一区| 亚洲电影中文字幕在线观看| 一个色在线综合| 一区二区视频免费在线观看| 亚洲裸体xxx| 亚洲一线二线三线久久久| 丝袜诱惑制服诱惑色一区在线观看| 亚洲精品网站在线观看| 亚洲免费看黄网站| 亚洲一级电影视频| 亚洲成a人v欧美综合天堂 | 老司机精品视频导航| 奇米精品一区二区三区四区 | 色婷婷综合中文久久一本| 91在线你懂得| 精品视频在线视频| 91麻豆精品国产91久久久久久| 日韩一区二区三区视频| 精品日产卡一卡二卡麻豆| 国产无一区二区| 综合欧美亚洲日本| 亚洲1区2区3区视频| 秋霞午夜av一区二区三区| 久久国产免费看| 成人高清av在线| 色88888久久久久久影院按摩| 在线不卡一区二区| 精品国产乱码久久久久久牛牛| 久久久天堂av| 亚洲美女免费在线| 青娱乐精品在线视频| 成人黄色网址在线观看| 欧美日韩免费一区二区三区视频| 欧美一二区视频| 国产精品久99| 五月天婷婷综合| 成人久久久精品乱码一区二区三区| 色综合中文字幕国产| 91精品国产高清一区二区三区蜜臀| 久久综合色综合88| 一区二区激情小说| 国产一区二区三区黄视频| 91久久精品一区二区三区| 精品日韩成人av| 亚洲福中文字幕伊人影院| 国产成人鲁色资源国产91色综| 欧美丝袜丝交足nylons| 国产色婷婷亚洲99精品小说| 性做久久久久久免费观看| 粉嫩在线一区二区三区视频|