Exemplo n.º 1
0
MV_Vector operator-(const MV_Vector &x, const MV_Vector &y)
{
      unsigned int N = x.size();
      if (N != y.size())
      {
         cout << "Incompatible vector lengths in -." << endl;
         exit(1);
      }
      
      MV_Vector result(N);
      for (unsigned int i=0;i<N; i++)
         result(i) = x(i) - y(i);
      return result;
}
Exemplo n.º 2
0
real dot(const MV_Vector &x, const MV_Vector &y)
{
        
  //  Check for compatible dimensions:
  if (x.size() != y.size())
      {
         cout << "Incompatible dimensions in dot(). " << endl;
         exit(1);
      }

      real temp =  0;
      for (unsigned int i=0; i<x.size();i++)
           temp += x(i)*y(i);
      return temp;
}
Exemplo n.º 3
0
MV_Vector operator*(const real &a, const MV_Vector &x)
{
      int N = x.size();
      MV_Vector result(N);
      for (int i=0;i<N;i++)
         result(i) = x(i)*a;
      return result;
}
Exemplo n.º 4
0
double Maxim(MV_Vector<double> Gradient)
{
	double maxim = Gradient(0);
	for (int i = 0; i < Gradient.size(); i++)
		if (Gradient(i) > maxim)
			maxim = Gradient(i);
	return maxim;
}
Exemplo n.º 5
0
MV_Vector operator*(const MV_Vector &x, const real &a)
{
    // This is the other commutative case of vector*scalar.
    // It should be just defined to be
    // "return operator*(a,x);"
    // but some compilers (e.g. Turbo C++ v.3.0) have trouble
    // determining the proper template match.  For the moment,
    // we'll just duplicate the code in the scalar * vector 
    // case above.

      int N = x.size();
      MV_Vector result(N);
      for (int i=0;i<N;i++)
         result(i) = x(i)*a;
      return result;

}
Exemplo n.º 6
0
bool WavesSparseDS::fillJcol(MV_Vector<int>& jcol_vector, const int no_nonzero)

{
	// redimIrow must be called prior to fillJcol!
	// general use:  redimIrow - compute jcol_vector - fillJcol

	bool b = (jcol_arr.size() != no_nonzero) ? true : false;

	if (irow(nrows) != no_nonzero || jcol_vector.size() < no_nonzero)
	{
		cout << "WavesSparseDS::fillJcol irow and jcol are not consistent.\n" << flush;
	}

	jcol_arr.newsize(no_nonzero); //redim and copy

	for (int i = 0; i < no_nonzero; i++)
		jcol_arr(i) = jcol_vector(i);
	nonzeroes = jcol_length = jcol_arr.size(); // exact length
	diagonal_computed = false; //the diagonal is not yet computed

	return b;
}