question of outer_prod(ublas)

Oct 2, 2010 at 8:25am
I want to evaluate the outer product of two vectors
v1 = (-1, 0, 1), v2 = (0. -1, 1). Below is my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>
using std::endl;
using std::cout;

#include<boost/numeric/ublas/io.hpp>
#include<boost/numeric/ublas/matrix.hpp>
#include<boost/numeric/ublas/vector.hpp>
using namespace boost::numeric::ublas;


void testOuterProduct()
{  
  const int SIZE = 3;
  
  typedef boost::numeric::ublas::vector<int> vct;
  vct x(SIZE);
  vct y(SIZE);
  //matrix<int> result(SIZE, SIZE);  

  x[0] = -1;
  x[1] = 0;
  x[2] = 1;
  y[0] = 0;
  y[1] = -1;
  y[2] = 1;
  
  cout<<outer_prod(x, y)<<endl;  
}


This is the result
 
[3, 3]((0, 1, -1),(0, 0, 0),(0, -1, 1))


But the outer product of v1 and v2 should be (1, 1, 1)
Do I misunderstand anything?
Thanks
Last edited on Oct 2, 2010 at 8:26am
Oct 2, 2010 at 10:18am
You're probably confusing outer product with cross product..
Oct 2, 2010 at 10:42am
sorry, I am really confusing with cross product
Thanks for your help
Topic archived. No new replies allowed.