Esempio n. 1
0
void Vector :: AddElementVector (const ARRAY<INDEX> & pnum,
				 const BaseVector & elvec)
{
  int i;
  const Vector & helvec = elvec.CastToVector();
  for (i = 1; i <= pnum.Size(); i++)
    Elem(pnum.Get(i)) += helvec.Get(i);
}
Esempio n. 2
0
void Vector :: GetElementVector (const ARRAY<INDEX> & pnum,
				 BaseVector & elvec) const
{
  int i;
  Vector & helvec = elvec.CastToVector();
  for (i = 1; i <= pnum.Size(); i++)
    helvec.Elem(i) = Get(pnum.Get(i));
}
Esempio n. 3
0
void Vector :: GetPart (int startpos, BaseVector & v2) const
{
  Vector & hv2 = v2.CastToVector();

  if (Length() >= startpos + v2.Length() - 1)
    {
      const double * p1 = &Get(startpos);
      double * p2 = &hv2.Elem(1);
      
      memcpy (p2, p1, hv2.Length() * sizeof(double));
    }
  else
    MyError ("Vector::GetPart: Vector to short");
}
Esempio n. 4
0
double Vector :: operator* (const BaseVector & v2) const
  {
  const Vector & hv2 = v2.CastToVector();

  double sum = 0;
  double * p1 = data;
  double * p2 = hv2.data;

  if (Length() == hv2.Length())
    {
    for (INDEX i = Length(); i > 0; i--)
      {
      sum += (*p1) * (*p2);
      p1++; p2++;
      }
    }
  else
    (*myerr) << "Scalarproduct illegal dimension" << endl;
  return sum;
  }
Esempio n. 5
0
void Vector :: AddPart (int startpos, double val, const BaseVector & v2)
{
  const Vector & hv2 = v2.CastToVector();
  INDEX i;
  INDEX n = v2.Length();

  if (Length() >= startpos + n - 1)
    {
      double * p1 = &Elem(startpos);
      const double * p2 = &hv2.Get(1);

      for (i = 1; i <= n; i++)
	{
	  (*p1) += val * (*p2);
	  p1++;
	  p2++;
	}
    }
  else
    MyError ("Vector::AddPart: Vector to short");
}
Esempio n. 6
0
void Vector :: Swap (BaseVector & v2)
  {
  Vector & hv2 = v2.CastToVector();
  swap (length, hv2.length);
  swap (data, hv2.data);
  }