Ejemplo n.º 1
0
//////////////////////////////////////////////////////////////////////
// difference of two matrices
//////////////////////////////////////////////////////////////////////
MATRIX operator-(const MATRIX& A, const MATRIX& B)
{
  MATRIX result(A.rows(), A.cols());
  for (int y = 0; y < A.cols(); y++)
    for (int x = 0; x < A.rows(); x++)
      result(x,y) = A(x,y) - B(x,y);
  return result;
}
Ejemplo n.º 2
0
//////////////////////////////////////////////////////////////////////
// Scale matrix
//////////////////////////////////////////////////////////////////////
MATRIX operator*(float alpha, const MATRIX& A) 
{
  MATRIX y(A.rows(), A.cols());

  for (int i = 0; i < A.rows(); i++)
    for (int j = 0; j < A.cols(); j++)
      y(i,j) = A(i, j) * alpha;

  return y;
}
Ejemplo n.º 3
0
//////////////////////////////////////////////////////////////////////
// Vector-matrix multiply
//////////////////////////////////////////////////////////////////////
VECTOR operator*(VECTOR& x, MATRIX& A)
{
  assert(A.rows() == x.size());

  VECTOR y(A.cols());
  for (int i = 0; i < A.cols(); i++)
    for (int j = 0; j < A.rows(); j++)
      y[i] += A(j, i) * x(j);
  return y;
}
Ejemplo n.º 4
0
//////////////////////////////////////////////////////////////////////
// Matrix-vector multiply
//////////////////////////////////////////////////////////////////////
VECTOR operator*(const MATRIX& A, const VECTOR& x) 
{
  VECTOR y(A.rows());

  for (int i = 0; i < A.rows(); i++)
    for (int j = 0; j < A.cols(); j++)
      y(i) += x(j) * A(i, j);

  return y;
}
Ejemplo n.º 5
0
void DbScan::initialise(const MATRIX& X)
{
	points_.clear();
	Point point;
	for(unsigned i = 0; i < X.rows(); ++i)
	{
		point.id = i;
		points_.push_back(point);
	}
	
	distances_.getDistances(X);
}
Ejemplo n.º 6
0
Estimator<Mahalanobis>::Estimator(const MATRIX& X)
    : X_(&X)
{
    setBandwidth(scottBandwidth(X.rows(), X.columns(), 1.0));
    setCovariance(X.transpose()*X);
}