root / trunk / src / linad99 / tensprod.cpp @ 1611
History  View  Annotate  Download (809 Bytes)
1 
/*


2 
* $Id: tensprod.cpp 1611 20140205 06:33:29Z stevenmartell $

3 
*

4 
* Author: David Fournier

5 
* Copyright (c) 20082012 Regents of the University of California

6 
*/

7 
/**

8 
* \file

9 
* Description not yet available.

10 
*/

11 
#include <fvar.hpp> 
12  
13 
/**

14 
* The tensor product of two dvar_matrixes

15 
* \param a first dvar_matrix

16 
* \param b second dvar_matrix

17 
* \return c a dvar_matrix of the tensor product.

18 
*

19 
* Calcuates the tensor product of a and b.

20 
* \f$

21 
* C = A \otimes B

22 
* \f$

23 
*/

24 
dvar_matrix tensor_prod(const dvar_matrix& a,const dvar_matrix & b) 
25 
{ 
26 
int lba=a.indexmin();

27 
int lbb=b.indexmin();

28 
int uba=a.indexmax();

29 
int ubb=b.indexmax();

30 
dvar_matrix ta=trans(a); 
31 
dvar_matrix tb=trans(b); 
32 
dvar_matrix c(lba,uba,lbb,ubb); 
33 
for (int i=lba;i<=lbb;i++) 
34 
for (int j=lbb;j<=ubb;j++) 
35 
c(i,j)=ta(i)*tb(j); 
36 
return c;

37 
} 