public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: James Bergstra <bergstrj@iro.umontreal.ca>
To: Tuomo Keskitalo <Tuomo.Keskitalo@iki.fi>
Cc: Gerard Jungman <jungman@lanl.gov>,
	GSL Discuss Mailing List <gsl-discuss@sourceware.org>
Subject: Re: new double precision data structure?
Date: Mon, 28 Sep 2009 08:44:00 -0000	[thread overview]
Message-ID: <7f1eaee30909270934v7ae7f4a6u6cbf9d16b099978b@mail.gmail.com> (raw)
In-Reply-To: <4ABF1C3C.6070801@iki.fi>

I really like the idea of a GSL n-dimensional array, because it would
make it much easier to interoperate with numpy, scipy, and the other
tools which are developed in that community.

Compared to numpy's ndarray structure, there are only a few
differences with your proposal.

Firstly, the ndarray untyped.  The data is in a void * pointer or a
char * pointer or something, and there is an extra enum-valued field
that indicates what sort of elements make up the data.  For example, 0
might mean int8, 1 might mean uint8, 2 might mean int32, 10 might mean
float32, 11 float64, 12 complex64, and so on.  There is support for
non-native elements like structs and objects too.  We wouldn't need
all of that flexibility in the GSL, but the technique might be useful
for allocating and passing around tensors of integers, floats, complex
numbers.

Secondly, there is no notion of a 'layout' in the ndarray, so I wonder
if it is necessary here?  When you explicitly store the strides for
traversing the tensor in each dimension... what is left for the
'layout' to specify?

Thirdly, the dimensions are logical things, not physical ones.  So
perhaps they belong in the view rather than the base block?  I think
the simple { size_t n_allocated; char * buf } structure is sufficient
for the base block.

Fourthly, if you take the dimensions out of the base block, then they
need to into the view as well... so the view would wind up looking
something like:

{
int ndim;
size_t * dims; /* the size of the tensor in each of `ndim` dimensions */
int * strides;  /*negative strides are very useful */
gsl_type_t type; /* something like gsl_float32, gsl_float64,
gsl_complex128, etc. */
void * data;  /* pointer into the underlying block, not necessarily
the beginning */
base_block * base;
int owner; /* True -> free the base with ourselves */
}

The biggest advantage of moving the dimensions from the base_block to
the view that it allows in-place reshaping and transposing of views,
which would be awkward otherwise.

Macros / functions can make it convenient to get a properly-casted
pointer to the underlying data (returning NULL when the type being
asked for doesn't match the type of the data).  For example
gsl_view_data_float32(view).

James Bergstra
-- 
http://www-etud.iro.umontreal.ca/~bergstrj


On Sun, Sep 27, 2009 at 4:03 AM, Tuomo Keskitalo <Tuomo.Keskitalo@iki.fi> wrote:
> On 09/16/2009 03:49 AM, Gerard Jungman wrote:
>
>> It smells like a view, and indeed it is. But it is a notion of
>> view which is more central to the design than the current one.
>> Everything should be a view.
>
> I think we really need to sort the data structure out now.
>
> I'm not sure what you have in mind, but to get some discussion going on,
> I've attached an (incomplete and untested) idea for a general n-dimensional
> double precision data structure. Is this anything like what you pictured?
>
> I'd like to hear people's comments on this. Would something like this be of
> use? Feel free to give your full critique.
>
> --
> Tuomo.Keskitalo@iki.fi
> http://iki.fi/tuomo.keskitalo
>

  reply	other threads:[~2009-09-28  8:44 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 17:07 ode-initval implicit solvers and development Tuomo Keskitalo
2008-10-01 18:29 ` Brian Gough
2008-10-09 13:22 ` Brian Gough
2008-11-02 17:35 ` Tuomo Keskitalo
2008-11-03 18:09   ` Brian Gough
2009-01-24 11:52     ` Tuomo Keskitalo
2009-02-01 17:01       ` Brian Gough
2009-02-02 17:05         ` Tuomo Keskitalo
2009-03-01 14:37           ` Tuomo Keskitalo
2009-03-03 16:34             ` Brian Gough
2009-03-05 19:47               ` Tuomo Keskitalo
2009-03-05 19:54                 ` Heikki Orsila
2009-03-06 20:03                 ` Brian Gough
2009-04-05 12:28             ` Tuomo Keskitalo
2009-05-01 14:05             ` Tuomo Keskitalo
2009-05-04 11:23               ` Brian Gough
2009-05-08 10:51               ` Brian Gough
2009-08-06 13:51                 ` GSL 2.0 roadmap Tuomo Keskitalo
2009-08-21 20:42                   ` Brian Gough
2009-08-27 11:42                     ` Tuomo Keskitalo
2009-08-27 12:51                       ` Robert G. Brown
2009-08-28 13:57                         ` Jordi Burguet Castell
2009-08-27 17:13                           ` Robert G. Brown
2009-08-28 13:58                       ` Brian Gough
2009-08-27 23:10                     ` Gerard Jungman
2009-08-27 23:13                       ` GSL 2.0 roadmap (one man's view) Gerard Jungman
2009-08-28 13:58                         ` Brian Gough
2009-09-16  0:43                           ` Gerard Jungman
2009-09-03 19:37                         ` Brian Gough
2009-09-16  0:44                           ` Gerard Jungman
2009-09-07 15:10                         ` Brian Gough
2009-09-16  0:45                           ` Gerard Jungman
2009-09-20  9:36                             ` Tuomo Keskitalo
2009-09-20 13:23                               ` Robert G. Brown
2009-09-20 15:31                                 ` Rhys Ulerich
2009-09-20 16:19                                   ` Robert G. Brown
2009-09-21 15:13                                   ` Brian Gough
2009-09-20 15:08                               ` Rhys Ulerich
2009-09-21 12:08                               ` Brian Gough
2009-09-07 15:10                         ` Brian Gough
2009-09-07 15:34                           ` Rhys Ulerich
2009-09-07 18:21                             ` Robert G. Brown
2009-09-16  0:47                           ` Gerard Jungman
2009-09-18  3:51                             ` column-major Z F
2009-09-21 12:08                               ` column-major Brian Gough
2009-09-07 15:10                         ` GSL 2.0 roadmap (one man's view) Brian Gough
2009-09-16  0:44                           ` Gerard Jungman
2009-09-17 20:12                             ` Brian Gough
     [not found]                           ` <645d17210909090818u474f32f0q19a6334578b9f02c@mail.gmail.com>
2009-09-17 19:14                             ` Brian Gough
2009-09-07 15:10                         ` Brian Gough
2009-09-16  0:46                           ` Gerard Jungman
2009-09-17 20:12                             ` Brian Gough
2009-09-07 15:10                         ` Brian Gough
2009-09-16  0:46                           ` Gerard Jungman
2009-09-16  2:48                             ` Robert G. Brown
2009-09-17 19:14                             ` Brian Gough
2009-09-07 15:10                         ` Brian Gough
2009-09-16  0:47                           ` Gerard Jungman
2009-09-27  8:03                             ` new double precision data structure? Tuomo Keskitalo
2009-09-28  8:44                               ` James Bergstra [this message]
2009-09-28 15:48                                 ` Tuomo Keskitalo
2009-10-16 13:59                                   ` Brian Gough
2009-09-29 18:38                               ` Gerard Jungman
2009-08-28 13:58                     ` GSL 2.0 roadmap Brian Gough

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f1eaee30909270934v7ae7f4a6u6cbf9d16b099978b@mail.gmail.com \
    --to=bergstrj@iro.umontreal.ca \
    --cc=Tuomo.Keskitalo@iki.fi \
    --cc=gsl-discuss@sourceware.org \
    --cc=jungman@lanl.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).