## root / trunk / src / linad99 / tensprod.cpp @ 1611

History | View | Annotate | Download (809 Bytes)

1 | 417 | arnima | ```
/*
``` |
---|---|---|---|

2 | ```
* $Id$
``` |
||

3 | ```
*
``` |
||

4 | ```
* Author: David Fournier
``` |
||

5 | 1112 | johnoel | ```
* Copyright (c) 2008-2012 Regents of the University of California
``` |

6 | 417 | arnima | ```
*/
``` |

7 | ```
/**
``` |
||

8 | ```
* \file
``` |
||

9 | ```
* Description not yet available.
``` |
||

10 | ```
*/
``` |
||

11 | #include <fvar.hpp> |
||

12 | |||

13 | ```
/**
``` |
||

14 | 1611 | stevenmartell | ```
* 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 | 417 | arnima | ```
*/
``` |

24 | dvar_matrix tensor_prod(const dvar_matrix& a,const dvar_matrix & b) |
||

25 | { |
||

26 | 422 | johnoel | ```
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 | 417 | arnima | dvar_matrix c(lba,uba,lbb,ubb); |

33 | 422 | johnoel | for (int i=lba;i<=lbb;i++) |

34 | for (int j=lbb;j<=ubb;j++) |
||

35 | c(i,j)=ta(i)*tb(j); |
||

36 | 417 | arnima | ```
return c;
``` |

37 | } |