Esempio n. 1
0
double SpinAdapted::dotproduct(const RowVector& a, const RowVector& b)
{
  assert(a.Ncols() == b.Ncols());
#ifdef BLAS
  return DDOT(a.Storage(), a.Store(), 1, b.Store(), 1);
#else
  return a * b.t();
#endif
}
Esempio n. 2
0
static void TestSort(int n)
{
   // make some data
   RowVector X(n);
   int i;
   for (i = 1; i <= n; i++)
      X(i) = sin((Real)i) + 0.3 * cos(i/5.0) - 0.6 * sin(i/7.0) + 0.2 * sin(2.0 * i);
   RowVector X_Sorted = X; SimpleSortDescending(X_Sorted.Store(), n);
   RowVector A = X + X.Reverse(); SimpleSortDescending(A.Store(), n);

   // test descending sort

   RowVector Y = X; SortDescending(Y); Y -= X_Sorted; Print(Y);
   Y = X_Sorted; SortDescending(Y); Y -= X_Sorted; Print(Y);
   Y = X_Sorted.Reverse(); SortDescending(Y); Y -= X_Sorted; Print(Y);
   Y = X + X.Reverse(); SortDescending(Y); Y -= A; Print(Y);

   // test ascending sort

   Y = X; SortAscending(Y); Y -= X_Sorted.Reverse(); Print(Y);
   Y = X_Sorted; SortAscending(Y); Y -= X_Sorted.Reverse(); Print(Y);
   Y = X_Sorted.Reverse(); SortAscending(Y); Y -= X_Sorted.Reverse(); Print(Y);
   Y = X + X.Reverse(); SortAscending(Y); Y -= A.Reverse(); Print(Y);
}