help-octave
[Top][All Lists]
Advanced

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

Re: questions regarding liboctave


From: David Bateman
Subject: Re: questions regarding liboctave
Date: Tue, 05 Dec 2006 16:45:07 +0100
User-agent: Thunderbird 1.5.0.7 (X11/20060921)

Gorazd Brumen wrote:
> Hi,
> 
> I have the following questions regarding liboctave:
> 
> 1. Is there a method that computes the fft of a row or a column vector
> and how is it called?

ColumnVector a
Matrix b = Matrix(a).fourier();


> 2. What is the most effective way to compute the scalar product of two
> vectors?

const ColumnVector a
const ColumnVector b
octave_idx_type mn = (a.length() < b.length() ? a.length() : b.length());
ColumnVector c(mn);
const double *avec = a.fortran_vec();
const double *bvec = b.fortran_vec()
double *cvec = c.fortran_vec();
for (octave_idx_type i = 0; i < mn; i++)
  cvec[i] = avec[i] * bvec[i];


> 
> 3. Does the method append on the Matrix class append a column (row)
> vector at the end of the matrix? What if I want to append a row
> vector to another row vector or a col. vector to another col vector?
> Do I have to transform things into matrices?


append always appends to the right of the matrix. The method stack
appends under the existing matrix. Yes you have to transform to a
matrix. For example

RowVector a
Matrix b (a);
b.stack(a);


> 4. I have the following functions
> 
> float trans (ColumnVector z, float t, ColumnVector x, Cell params) {
> 
>   return tp (z - x, params(0) * t, params(1) * sqrt (t) );
> 
> }
> 
> float tp (ColumnVector x, ColumnVector mu, Matrix sigma) { // here
> follows code }

That would be better like

double trans (const ColumnVector &z, double t, const ColumnVector &x,
const Cell &params) {
  return tp(z - x, params(0)* t, params(1) * sqrt(t));
}



> 
> 
> 
> 
> I get from running the compiler:
> 
> rhs.cc: In function ‘float trans(ColumnVector, float, ColumnVector, Cell)’:
> rhs.cc:101: error: conversion from ‘octave_value’ to non-scalar type
> ‘ColumnVector’ requested
> 
> 
> What is wrong?

Don't know, need a complete example. There isn't enough context to tell.

> 
> 
> Please excuse me, I have not read ALL the documentation about the classes.
> 
> Gorazd
> 
> 

D.


reply via email to

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