octave-maintainers
[Top][All Lists]
Advanced

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

Re: GSL in octave


From: Julien Bect
Subject: Re: GSL in octave
Date: Thu, 21 Jul 2016 09:08:21 +0200
User-agent: SOGoMail 2.3.6

Le Jeudi 21 Juillet 2016 08:15 CEST, Susi Lehtola <address@hidden> a écrit:

> > 3) In the changeset "It's better to use row vectors instead" (really...
> > can't you try to write more explicit commit messages ?) you modify all
> > templates in such a way that all functions now return row vectors.  This
> > is a little unexpected (and not documented).  For instance,
> >
> > debye_1 (rand (3, 3))
> > ans =
> >
> >    0.91844   0.84803   0.93841   0.88165   0.99141   0.79339 0.85979
> > 0.84939   0.94766
> >
> > whereas I would have expected a 3 x 3 output.
>
> Well, obviously that will have to be documented, or changed. The reason
> why I made this change and the assumption that size doesn't matter is
> that otherwise you'll get into huge problems when you have more than one
> argument. If you give this function a row and a column vector as
> arguments, then you should get out a matrix. However, if the two
> arguments are matrices, then the output should be a rank-4 tensor, which
> becomes very quickly challenging.
>
> And the biggest functions in octave-gsl have four arguments, which means
> the result with four matrix arguments will be a rank-8 tensor, which 
> wouldn't fit into memory.
>
> > 4) Just an idea: for functions with several arguments, it would be
> > really nice (but I don't how hard) to implement broadcasting:
> >
> > conicalP_0 ([1 4 3]', [2 3])  # should return a 3 x 2 matrix as a result
>
> See answer above.

I think we have a misunderstanding about what "broadcast" means.

Even if you have a function with four arguments, broadcasting (as I understand 
it) doesn't mean that you will end up with a 4-dimensional (or 8-dimensional 
???) array.

For instance, if you have (x, y, z) where x is a row of length m, y a column of 
length n, and z an m x n matrix, then you would get an m x n matrix.

Broadcasting is documented in the manual for the case of binary operations:

https://www.gnu.org/software/octave/doc/v4.0.0/Broadcasting.html

but the same principle can be generalized to any number of arguments.  See for 
instance what the common_size () function does.

Broadcasting is supported for all basic operations in Octave (plus, minus, 
times, rdivide, etc.)






reply via email to

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