Covariant Vector Dot Product

Synopsis

Dot product of Vectors

Results

Output:

u :[-1, 1, -1]
v :[1, 2, 3]
DotProduct( u, v ) = -2
u - DotProduct( u, v ) * v = [1, 5, 5]

Code

C++

#include "itkVector.h"

int
main(int, char *[])
{
  constexpr unsigned int Dimension = 3;
  using CoordType = double;

  using VectorType = itk::Vector<CoordType, Dimension>;

  VectorType u;
  u[0] = -1.;
  u[1] = 1.;
  u[2] = -1.;

  VectorType v;
  v[0] = 1.;
  v[1] = 2.;
  v[2] = 3.;

  std::cout << "u :" << u << std::endl;
  std::cout << "v :" << v << std::endl;
  std::cout << "DotProduct( u, v ) = " << u * v << std::endl;
  std::cout << "u - ( u * v ) * v = " << u - (u * v) * v << std::endl;

  return EXIT_SUCCESS;
}

Classes demonstrated