Classes Utilities Scripts Speech Search Up Home
ISIP IFC Index
Title Bar

/home5/piconepr/public_html/isip/projects/speech/software/documentation/class/math/matrix/MMatrix/mmat_09.cc

// file: $isip/class/math/matrix/MMatrix/mmat_09.cc
// version: $Id: mmat_09.cc 7924 2002-03-15 23:30:38Z zheng $
//

// isip include files
//
#include "MMatrixMethods.h"
#include "MMatrix.h"

[snipped]

// method: sub
//
// arguments:
//  MMatrix<TScalar, TIntegral>& this: (output) class operand
//  TIntegral value: (input) scalar value
//
// return: a boolean value indicating status
//
template<class TScalar, class TIntegral>
boolean MMatrixMethods::sub(MMatrix<TScalar, TIntegral>& this_a, 
			    TIntegral value_a) {

  // get the type of the matrix and branch on type
  //
  Integral::MTYPE type = this_a.getType();
  
  // if the current matrix is a sparse, change it to full for the
  // computation. this is admittedly inefficient, but there is really
  // no way for this computation to be efficient anyway.
  //
  if (type == Integral::SPARSE) {
    this_a.changeType(Integral::FULL);
  }

  //  now we simply need to subtract the value to the storage vector
  //
  if (!this_a.m_d.sub(value_a)) {
    return false;
  }

  // for sparse we need to change the type back
  //
  if (type == Integral::SPARSE) {
    this_a.changeType(Integral::SPARSE);
  }

  // exit gracefully
  //
  return true;
}

[snipped]

//
// end of file


Footer

Up | Home | Courses | Projects | Proposals | Publications
Please direct questions or comments to joseph.picone@isip.piconepress.com