Multiplying matrices: var and double

6 views
Skip to first unread message

Daniel Lee

unread,
Jan 2, 2012, 11:32:08 PM1/2/12
to stan...@googlegroups.com
We can't multiply Eigen matrices of double and var together. I found
this out while trying to get the Wishart distribution to compile for
vars.

I just checked in tests for Wishart. Some of them fail. I'll get them
to pass once we are able to multiply matrices together.

Regarding the multiplication, thoughts on how to make multiplication
work generally?

Bob Carpenter

unread,
Jan 3, 2012, 1:57:03 AM1/3/12
to stan...@googlegroups.com
You need to use stan::maths and stan::agrad matrix
functions. They're there exactly because they
auto-promote double matrices to var matrices. All
of the ops there are defined for all mixed types.

The bummer is that we lose all the template
expression goodness, like lazy evaluation of
intermediates. At least all the really expensive
matrix operations like solving are with single-typed
matrices.

I asked the Eigen developers and they say it's
going to require some work on their side with traits
to get two differently typed matrices to work together.
So far, it's only possible with regular and complex,
but the same logic would work for regular and auto-dif.

- Bob

Reply all
Reply to author
Forward
0 new messages