コード例 #1
0
ファイル: matrix.cpp プロジェクト: Nasrollah/cfd3d
//operator overload for division with a scalar
squareMatrix operator/ (const double &scalar, const squareMatrix &s2){
  squareMatrix s1(s2.Size());

  int cc = 0;
  int rr = 0;
  for( cc = 0; cc < s2.Size(); cc++ ){
    for( rr = 0; rr < s2.Size(); rr++ ){
      s1.SetData(rr,cc, scalar / s2.Data(rr,cc));
    }
  }
  return s1;
}
コード例 #2
0
ファイル: matMultiArray3d.hpp プロジェクト: mnucci32/aither
 void SubtractFromFlow(const int &ii, const int &jj, const int &kk,
                       const squareMatrix &jac) {
   MSG_ASSERT(jac.Size() == this->FlowSize(), "block size must match");
   std::transform(this->BeginFlow(ii, jj, kk), this->BeginTurb(ii, jj, kk),
                  jac.begin(), this->BeginFlow(ii, jj, kk),
                  std::minus<double>());
 }
コード例 #3
0
ファイル: matrix.cpp プロジェクト: Nasrollah/cfd3d
//operator overload for subtraction
squareMatrix squareMatrix::operator - (const squareMatrix& s2)const{
  squareMatrix s1 = *this;

  //check to see that matrix dimensions are the same
  if ( s1.size != s2.size ){
    cerr << "ERROR: Cannot subtract matrices, dimensions do not agree." << endl;
  }

  int cc = 0;
  int rr = 0;
  for( cc = 0; cc < s2.Size(); cc++ ){
    for( rr = 0; rr < s2.Size(); rr++ ){
      s1.SetData(rr,cc, s1.Data(rr,cc) - s2.Data(rr,cc));
    }
  }
  return s1;
}
コード例 #4
0
ファイル: matrix.cpp プロジェクト: Nasrollah/cfd3d
//operator overload for multiplication
squareMatrix squareMatrix::operator * (const squareMatrix& s2)const{
  squareMatrix s1 = *this;

  //check to see that matrix dimensions are the same
  if ( s1.size != s2.size ){
    cerr << "ERROR: Cannot multiply matrices, dimensions do not agree." << endl;
  }

  int cc = 0;
  int rr = 0;
  for( cc = 0; cc < s2.Size(); cc++ ){
    for( rr = 0; rr < s2.Size(); rr++ ){
      double newVal = 0.0;
      int ii = 0;
      for( ii = 0; ii < s2.Size(); ii++ ){
	newVal += ((*this).Data(rr,ii) * s2.Data(ii,cc));
      }
      s1.SetData(rr,cc, newVal);
    }
  }
  return s1;
}
コード例 #5
0
ファイル: matrix.cpp プロジェクト: Nasrollah/cfd3d
//copy constructor
squareMatrix::squareMatrix( const squareMatrix &cp){
  (*this).size = cp.Size();
  (*this).data = new double[cp.Size()*cp.Size()];
  copy(&cp.data[0], &cp.data[0] + cp.Size()*cp.Size(), &(*this).data[0]);
}