示例#1
0
/**
   the special constructor
  */
aVector::aVector(const aVector& v)
{
// make sure that the sizes match!
   pv_size = 3;
   
   if ( pv_size != v.pv_size )
   {
#ifdef DEBUG_ON
   // raise an exception! presently take recourse to exit
      cerr << "Cannot build vector. Sizes don't match!"
           << endl
           << "Program exiting :-("
           << endl;
      exit(-1);
#endif
   }

   pv_p    = new double[pv_size];  // allocate space

   pv_p[0] = v.pv_p[0];
   pv_p[1] = v.pv_p[1];
   pv_p[2] = v.pv_p[2];

   pv_magnitude = v.pv_magnitude;    

   pv_is_null   = isNullVector();

   pv_bln_true  = TRUE;
   pv_bln_false = FALSE;
}
示例#2
0
/**
 * Transforma a matriz de entrada em uma matriz estocástica:
 * a - Se uma linha da matriz é nula todos os elementos são substituidos por 1.
 * b - A soma de todos os elementos de uma linha deve dar 1.
 * @param matrix  Ponteiro para uma matriz.
 * @param lines   Quantidade de linhas na dada matriz.
 * @param columms Quantidade de colunas na dada matriz.
 */
void stochasticMatrix(double **matrix, unsigned lines, unsigned columms) {
  unsigned i;
  for (i = 0; i < lines; i++) {
    if (isNullVector(matrix[i], columms) == true)
      setVectorToOne(matrix[i], columms);

    normalizeVector(matrix[i], columms);
  }
}
示例#3
0
/**
   sets the vector to new components.
  */
void aVector::SetVector(double p0, double p1, double p2)
{
   pv_p[0] = p0;
   pv_p[1] = p1;
   pv_p[2] = p2;

// recompute magnitute and nullity
   ComputeMagnitude();
   pv_is_null = isNullVector();
}
示例#4
0
/**
   set the i-th component of the vector
  */
void aVector::SetAComp(int i, double p_val)
{
#ifdef CHECKBOUNDS_ON
   CheckBounds(i);
#endif

   pv_p[i] = p_val;

// recompute magnitude and nullity
   ComputeMagnitude();
   pv_is_null = isNullVector();
}
示例#5
0
/**
   this constructor builds the vector with the values passed
   (the components in the stated order)
  */
aVector::aVector(double p0, double p1, double p2)
   : pv_size(3)
{
   pv_p    = new double[pv_size];  // allocate space
   pv_p[0] = p0;
   pv_p[1] = p1;
   pv_p[2] = p2;

   ComputeMagnitude();    // compute and store vector mag

   pv_is_null   = isNullVector();

   pv_bln_true  = TRUE;
   pv_bln_false = FALSE;
}