RE: [Boost-Users] Getting a matrix to the power of n
Hi Unless I've missed something, I don't think uBlas provides a way to do this (other than the _very_ inefficient prod(A, A) in a loop). If you need to do this frequently with large matrices and/or large powers (n) then you'll need to look at diagonalizing your matrix using eigenvalue/vector decomposition. This reduces your task to raising the values on the diagonal of a diagonal matrix to the power of n and doing two matrix multiplies and an inverse. Finding the eigenvalues and corresponding eigenvectors of your matrix is a non-trivial task which imposes some restrictions on your matrix. Refer to "Numerical recipes in C" by Press et al. for some guidance as well as any good textbook on linear algebra. Hope this helps, Scott
-----Original Message----- From: agiatojon [mailto:JonAgiato@nyc.rr.com] Sent: 14/11/2002 14:17 To: Boost-Users@yahoogroups.com Subject: [Boost-Users] Getting a matrix to the power of n
Hello all, I am working with a formula which requires me to get the result of a matrix to the power of n (i.e. pow(matrix, n)) but as expected, the <cmath> function pow() is unable to convert from type double to matrix. Does the matrix library have this sort of functionality built in, or maybe some other part of boost? Thanks!
Jon Agiato JonAgiato@nyc.rr.com
The contents of this email may be confidential. Unauthorised use is prohibited. Umgeni Water does not accept liability for any statements and opinions which are the sender's own view and not expressly made on its behalf.
Hi Scott, Thanks for the advice! It is a very small piece of code, so I am not extremely concerned about performance in that area. In reference to using prod(A, A) in a loop, how would one do such a thing if the power was negative, as if we are looking for a matrix to the power of -1, -2, or -3? Thanks again! Jon Agiato JonAgiato@nyc.rr.com ----- Original Message ----- From: Scott Sinclair To: 'Boost-Users@yahoogroups.com' Sent: Thursday, November 14, 2002 8:00 AM Subject: RE: [Boost-Users] Getting a matrix to the power of n Hi Unless I've missed something, I don't think uBlas provides a way to do this (other than the _very_ inefficient prod(A, A) in a loop). If you need to do this frequently with large matrices and/or large powers (n) then you'll need to look at diagonalizing your matrix using eigenvalue/vector decomposition. This reduces your task to raising the values on the diagonal of a diagonal matrix to the power of n and doing two matrix multiplies and an inverse. Finding the eigenvalues and corresponding eigenvectors of your matrix is a non-trivial task which imposes some restrictions on your matrix. Refer to "Numerical recipes in C" by Press et al. for some guidance as well as any good textbook on linear algebra. Hope this helps, Scott
-----Original Message----- From: agiatojon [mailto:JonAgiato@nyc.rr.com] Sent: 14/11/2002 14:17 To: Boost-Users@yahoogroups.com Subject: [Boost-Users] Getting a matrix to the power of n
Hello all, I am working with a formula which requires me to get the result of a matrix to the power of n (i.e. pow(matrix, n)) but as expected, the <cmath> function pow() is unable to convert from type double to matrix. Does the matrix library have this sort of functionality built in, or maybe some other part of boost? Thanks!
Jon Agiato JonAgiato@nyc.rr.com
The contents of this email may be confidential. Unauthorised use is prohibited. Umgeni Water does not accept liability for any statements and opinions which are the sender's own view and not expressly made on its behalf. Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. [Non-text portions of this message have been removed]
Hi Scott,
Thanks for the advice! It is a very small piece of code, so I am not extremely concerned > about performance in that area. In reference to using
----- Original Message ----- From: Jon Agiato To: Boost-Users@yahoogroups.com Sent: Thursday, November 14, 2002 3:07 PM Subject: Re: [Boost-Users] Getting a matrix to the power of n prod(A, A) in a loop, how would
one do such a thing if the power was negative, as if we are looking for a matrix to the power of -1, -2, or -3? Thanks again!
The case -1 is equivalent to solving a system of linear equations A X = Id. There are a couple of well known methods (*not* part of uBLAS) to do this.
From Scott:
Unless I've missed something, I don't think uBlas provides a way to do this (other than the _very_ inefficient prod(A, A) in a loop). If you need to do this frequently with large matrices and/or large powers (n) then you'll need to look at diagonalizing your matrix using eigenvalue/vector decomposition. This reduces your task to raising the values on the diagonal of a diagonal matrix to the power of n and doing two matrix multiplies and an inverse.
Finding the eigenvalues and corresponding eigenvectors of your matrix is a non-trivial task which imposes some restrictions on your matrix. Refer to "Numerical recipes in C" by Press et al. for some guidance as well as any good textbook on linear algebra.
Agreed. Best regards Joerg
participants (3)
-
jhr.walter@t-online.de
-
Jon Agiato
-
Scott Sinclair