[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More DLD mysteries
From: |
Al Niessner |
Subject: |
Re: More DLD mysteries |
Date: |
Mon, 15 Mar 2004 13:57:08 -0800 |
Sorry it took so long, but I am just getting back to this. So, if Matrix
is two dimensional and any() and all() reduce the order by one, then why
do they return a Matrix? ColumnVector and RowVector are the one
dimensional counterparts. I would then think that ColumnVector any() or
all() would reduce to a scalar (boolean actually). However, there is no
any() or all() for {Column,Row}Vector. So, I have to do something like:
ColumnVector c;
...
c = ...;
if ((Matrix(c) < SomeDelta).bool_matrix_value().any()(0,0))
{
...do something significant maybe...
}
The point here being I have no idea if the conditional in the C++ if
statement is the same as my m-file of 'if (any(c < SomeDelta))'. There
is nothing in any header file in the include/octave... directory that
helps to clear it up. It does compile, so we will see.
Thanks for the help.
On Tue, 2004-03-09 at 17:09, JD Cole wrote:
> Al,
> At first glance, it looks like an argument gets passed to 'any' or
> 'all', if you don't want to specify a dimension, pass -1 (see
> src/data.cc ANY_ALL macro). They both also reduce the dimensionality by
> one, similar to when we do max(max(some_2d_matrix)), so if your mattrix
> is 2d, use any/all twice and then use then index the "top-left" item of
> the bools matrix returned.
>
> Hope this helps,
>
> JD
>
> Al Niessner wrote:
>
> >I am now looking for all() and any(). I have the expression "if any (a <
> >b)" and "if all (b < a)" type of thing in my m-file. I cannot find an
> >equivalent function that reduces to a boolean in the header files. I
> >tried "if (boolMatrix(a < b).any()) but that fails at compilation
> >because it returns yet another matrix and not a boolean. Any suggestions
> >are welcome and thanks in advance.
> >
> >
> >
--
Al Niessner <address@hidden>
Jet Propulsion Laboratory
All opinions stated above are mine and do not necessarily reflect
those of JPL or NASA.
----
| dS | >= 0
----
-------------------------------------------------------------
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
-------------------------------------------------------------