[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is_complex_nd_array() ?
From: |
Max Brister |
Subject: |
Re: is_complex_nd_array() ? |
Date: |
Thu, 16 Aug 2012 18:42:00 -0500 |
On Thu, Aug 16, 2012 at 6:18 PM, jjg <address@hidden> wrote:
>
> Max Brister wrote
>>
>> Using grep in the development source it looks like is_real_nd_array is
>> cruft that should be removed.
>>
>> You should use is_real_type and is_complex_type instead.
>>
>
> Thank you Max, finally I have a working check :
>
> if (! ( args(0).is_matrix_type() &&
> (args(0).is_real_type() ||
> args(0).is_complex_type())))
> {
> octave_stdout << "first argument must be a real or complex array\n";
> return octave_value_list();
> }
You have to be a little careful here. Your check will fail for 1x1
arrays. For example, your function would fail if called like
foobar ([1]);
This is because internally 1x1 arrays are scalars. If you do want the
test to fail for 1x1 arrays, a better way of writing the test is
if (! (args(0).is_real_matrix () || args(0).is_complex_matrix ())
...
> Bizzarely, is_matrix_type() is true for matrices and NDarrays.
>
> I could see that is_nd_array_type() (which does not exist)
> would be true for matrices, but an NDarray is a matrix type???
Matrix is a subclass of NDArray in Octave. I'm not sure why
is_real_nd_array even exists, it looks like it always returns false.
> No matter, I have my check working.
>
--
Max Brister
- is_complex_nd_array() ?, jjg, 2012/08/16
- Re: is_complex_nd_array() ?, Max Brister, 2012/08/16
- Re: is_complex_nd_array() ?, jjg, 2012/08/16
- Re: is_complex_nd_array() ?,
Max Brister <=
- Re: is_complex_nd_array() ?, jjg, 2012/08/16
- Re: is_complex_nd_array() ?, Max Brister, 2012/08/16
- Re: is_complex_nd_array() ?, jjg, 2012/08/16
- Re: is_complex_nd_array() ?, Max Brister, 2012/08/16
- Re: is_complex_nd_array() ?, jjg, 2012/08/17
- Re: is_complex_nd_array() ?, Jordi Gutiérrez Hermoso, 2012/08/17
- Re: is_complex_nd_array() ?, jjg, 2012/08/17
- Re: is_complex_nd_array() ?, Jordi Gutiérrez Hermoso, 2012/08/18
- Re: is_complex_nd_array() ?, jjg, 2012/08/18
- Re: is_complex_nd_array() ?, Jordi Gutiérrez Hermoso, 2012/08/17