help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matrix Power (was Re: Matrix quotent)


From: flatmax
Subject: Re: Matrix Power (was Re: Matrix quotent)
Date: Thu, 19 Oct 2000 14:14:40 +1100 (EST)

I have found the function 'elem_xpow (const Matrix& a, const Matrix& b)'
and have altered it based on the assumption that the results are never
complex .... it was from the file 'src/xpow.cc'
It looks like so :
// -*- 4 -*-
Matrix
elem_xpow (const Matrix& a, const Matrix& b)
{
  
  int nr = a.rows ();
  int nc = a.cols ();
  
  int b_nr = b.rows ();
  int b_nc = b.cols ();
  
  if (nr != b_nr || nc != b_nc)
    {
      gripe_nonconformant ("operator .^", nr, nc, b_nr, b_nc);
      //return octave_value ();
    }
  Matrix result (nr, nc);
  
  for (int j = 0; j < nc; j++)
    for (int i = 0; i < nr; i++)
      result (i, j) = pow (a (i, j), b (i, j));
  
  return result;
}


Matt

On Thu, 19 Oct 2000, flatmax wrote:

> Ooops, I realise I actually want to find the power of one matrix raised to
> the other .... for example :
>    int r=64, p=3;
>    RowVector onesP(p+1,1);
>    ColumnVector onesR(r,1);
>    ColumnVector spanR(r);
>    RowVector spanP(p+1);   
> 
> In octave pseudo code I would like to find the following :
>       b=(spanR * onesP).^(onesR * spanP);
> Any ideas ?
> thanks
> Matt
> 
> 
> 
> -----------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
> How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
> Subscription information:  http://www.che.wisc.edu/octave/archive.html
> -----------------------------------------------------------------------
> 




-----------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
Subscription information:  http://www.che.wisc.edu/octave/archive.html
-----------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]