[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Matrix like operations in a .oct file
From: |
babelproofreader |
Subject: |
Re: Matrix like operations in a .oct file |
Date: |
Thu, 3 Oct 2013 15:03:47 -0700 (PDT) |
Kai Torben Ohlhus-2 wrote
> On Wed, Oct 2, 2013 at 5:22 PM, babelproofreader <
> babelproofreader@
> > wrote:
>
>> I'd like to write concise code in a .oct file to perform matrix
>> multiplication on the input column vector. The function internally
>> creates,
>> for example, a row vector A of 11 elements, and then within a loop I want
>> to
>> perform A * B where B is an 11 element sliding window down the input
>> column
>> vector, writing the result to an output column vector as the loop
>> progresses. I've tried various approaches using the information on
>> http://wiki.octave.org/Tips_and_tricks but I can't get anything to
>> compile -
>> some of the typical errors I'm getting are:
>>
>> no matching function for call to ‘ColumnVector::extract(octave_idx_type,
>> int, octave_idx_type&, int)
>> cannot convert ‘RowVector’ to ‘double’ in assignment
>>
>> Any pointers?
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://octave.1599824.n4.nabble.com/Matrix-like-operations-in-a-oct-file-tp4657812.html
>> Sent from the Octave - General mailing list archive at Nabble.com.
>> _______________________________________________
>> Help-octave mailing list
>>
> Help-octave@
>> https://mailman.cae.wisc.edu/listinfo/help-octave
>>
>
> Hello,
>
> your problem description is too generic to give you some helpful advice.
> Can you provide a code sample you're trying to compile, your operating
> system and the octave version you are using?
>
> A good starting point for writing .oct-files is the manual:
> https://www.gnu.org/software/octave/doc/interpreter/Oct_002dFiles.html#Oct_002dFiles
>
> HTH, Kai
>
> _______________________________________________
> Help-octave mailing list
> Help-octave@
> https://mailman.cae.wisc.edu/listinfo/help-octave
the revelant part of my code is:-
Matrix price = args(0).matrix_value () ; // a single column matrix
Matrix output = args(0).matrix_value () ;
// create intermediate calculation matrices
Matrix vec_11 (1,11) ;
Matrix price_11 (11,1) ;
Matrix result (1,1) ;
for ( int ii = -m ; ii < (m+1) ; ii ++ )
{
vec_11 is filled in this loop and then doesn't change
}
for ( octave_idx_type ii (50) ; ii < args(0).length () ; ii++ )
{
// extract rolling window and perform matrix multiplication
result = vec_11 * price.extract(ii-10,0,ii,0) ;
output(ii,1) = result ; // this writing to output matrix fails
}
retval_list(0) = output ;
--
View this message in context:
http://octave.1599824.n4.nabble.com/Matrix-like-operations-in-a-oct-file-tp4657812p4657862.html
Sent from the Octave - General mailing list archive at Nabble.com.