Boost logo

Boost Users :

From: Angus Leeming (angus.leeming_at_[hidden])
Date: 2004-04-08 07:27:44


Russell Hind wrote:

> I have an expression
>
> a = (X^T * X)^-1 * X^T * y
>
> where x is an n * k matrix
> and y is an n row vector
>
> How do I implement this expression in ublas? I can create and
> populate the matrices and can do the product of matrices and the
> transpose use
> prod and trans, but I'm unsure on the ^-1. Can I do this with
> ublas?
>
> (I don't know much about matrices, but have been given the above
> expression as a way of finding a polynomial fit for a set of data).

Hi, Russell.

You are trying to solve a matrix expression.

        A = B^-1 * C*D
is equivalent to
        B*A = B*B^-1 * C*D
which collapses to
        B*A = C*D

So, you can reprase your problem as solve the system
        B*A = E
where B,E are known, E=C*D, to give the unknown A.

Have a look at the (undocumented :-() lu_factorize and lu_substitute
routines. They should enable you to complete the task.

HTH,

-- 
Angus

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net