help-octave
[Top][All Lists]

## Re: C++ template

 From: Henry F. Mollet Subject: Re: C++ template Date: Mon, 04 Oct 2004 10:15:35 -0700 User-agent: Microsoft-Entourage/10.1.1.2418

```I have an older version of octave (2.1.46) and I get
octave:2> a(6)==a(1,2)
error: single index only valid for row or column vector
error: evaluating binary operator `==' near line 2, column 5

I have to vectorize 'a' first before I can compare a(6) with a(1,2):
octave:2> b=vec(a);
octave:5> b(6)==a(1,2)
ans = 1

Will a newer version of Octave know what to do with a(6) if a is a 5x5
matrix?
Henry

on 10/4/04 5:12 AM, Stefan van der Walt at address@hidden wrote:

> I am not sure what you mean, since all the examples listed under "Linear
> Indexing" in the document below works as stated.
>
> octave:1> a = ones(5,5)
> a =
>
> 1  1  1  1  1
> 1  1  1  1  1
> 1  1  1  1  1
> 1  1  1  1  1
> 1  1  1  1  1
>
> octave:2> a(6)==a(1,2)
> ans = 1
>
> Which compares the 6th element of 'a' to the second in the first row.
> If you want to compare a(6) to the first two elements, you have to do
>
> octave:6> a(6)==a(1:2)
>
> or
>
> octave:7> a(6)==a([1 2])
>
> Regards
> Stefan
>
> On Mon, Oct 04, 2004 at 04:46:22AM -0500, Fredrik Bulow wrote:
>> hmm....
>>
>> Linear indexing (i.e. a(6)==a(1,2) for a 5x5 matrix) does not seem to be
>> implemented yet. Or can it be turned on in some way? (Linear indexing is
>> described in the below link.)
>>
>> The "find" function seems to be built on the idea that linear indexing
>> is available since find(eye(5)) does return [1 7 13 19 25]'.
>>
>> /Fredrik
>>
>> On Mon, 2004-10-04 at 07:19, Paul Thomas wrote:
>>> Fredrik Bulow wrote:
>>>
>>>> Thank you!
>>>>
>>>>
>>> You are more than welcome.
>>>
>>>>
>>>>
>>> Most octave programmes can be vectorised, although it is not always
>>> obvious how.  All that applies to Matlab, in this area, applies to
>>> octave as well.  The following technical note is therefore very useful
>>> and should be read by all octave/Matlab/Scilab/... users, regardless of
>>> which they use:
>>>
>>> http://www.mathworks.com/support/tech-notes/1100/1109.html
>>>
>>> The speedup that can be obtained is often more than that from writing a
>>> dynamically linked function - especially if the development time of the
>>> latter is taken into account.
>>>
>>> Best regards
>>>
>>> Paul T
>>>
>>
>>
>>
>> -------------------------------------------------------------
>> Octave is freely available under the terms of the GNU GPL.
>>
>> Octave's home on the web:  http://www.octave.org
>> How to fund new projects:  http://www.octave.org/funding.html
>> Subscription information:  http://www.octave.org/archive.html
>> -------------------------------------------------------------
>>
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
>

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

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

```