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

/home5/piconepr/public_html/isip/projects/speech/software/documentation/class/math/scalar/MScalar/mscl_02.cc

// file: $isip/class/math/scalar/MScalar/mscl_02.cc
// version: $Id: mscl_02.cc 8518 2002-08-02 23:46:56Z zheng $
//

// isip include files
//
#include "MScalarMethods.h"
#include "MScalar.h"
#include <Console.h>
#include <typeinfo>

[snipped]

// method: diagnose1
//
// arguments:
//  Integral::DEBUG level: (input) debug level for diagnostics
//
// return: logical error status
//
// this method tests bitwise operations.
//
template<class TScalar, class TIntegral>
boolean MScalarMethods::diagnose1(Integral::DEBUG level_a) {
  
  //--------------------------------------------------------------------
  //
  //  testing bitwise and integer-specific operations
  //
  //--------------------------------------------------------------------
  
  // declare local variables
  //
  TScalar val0;
  TScalar val1;
  TScalar val2;

  // set indentation
  //
  if (level_a > Integral::NONE) {
    Console::put(L"testing class-specific public methods: bitwise operations...\n");
    Console::increaseIndention();
  }
    
  // unless the type is floating point, test bitwise methods
  //
  if ((typeid(TIntegral) != typeid(float)) &&
      (typeid(TIntegral) != typeid(double))) {
    
    if (val0.band(6, 2) != 2) {
      return Error::handle(name(), L"band", Error::TEST, __FILE__, __LINE__);
    }
    
    if (val0.bor(6, 2) != 6) {
      return Error::handle(name(), L"bor", Error::TEST, __FILE__, __LINE__);
    }
    
    if (val0.bxor(6, 2) != 4) {
      return Error::handle(name(), L"bxor", Error::TEST, __FILE__, __LINE__);
    }
    
    if (val0.brs(6, 2) != 1) {
      return Error::handle(name(), L"brs", Error::TEST, __FILE__, __LINE__);
    }
    
    if (val0.bls(6, 2) != 24) {
      return Error::handle(name(), L"bls", Error::TEST, __FILE__, __LINE__);
    }
    
    // this is tricky with different lengths; constrain to 8 bits
    //
    if (((byte)val0.bcmpl((TIntegral)6) & (byte)0xFF) != (byte)0xF9) {
      return Error::handle(name(), L"bcmpl", Error::TEST, __FILE__, __LINE__);
    }
  }
  
  // reset indentation
  //
  if (level_a > Integral::NONE) {
    Console::decreaseIndention();
  }
    
  // 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