octave-maintainers
[Top][All Lists]
Advanced

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

thoughts about an extension: views


From: Jaroslav Hajek
Subject: thoughts about an extension: views
Date: Thu, 3 Jul 2008 11:41:05 +0200

Dear all,

I have been thinking about an extension that would solve (to some
extent) two of regularly reappearing user requests:
pass-by-reference (or equivalent functionality) and other than
one-based indexing.
The idea is to allow constructing a "constant view" and "assignable
view" from a regular array or cell array.
function cview(varname, bspc1, bspc2, ...)  % constant view
and
function aview(varname, bspc1, bspc2, ...) % assignable view

each bspc is in the form [lb, ub] or [lb, ub, nlb] (default nlb = 1).

The view object, when indexed (either by () or {} indexing) would
simply transform the index according to the bspcs (lb:ub) <--
(nlb:nlb-lb+ub) and forward the indexing to the "parent" object. cview
would allow only value indexing (subsref), aview would also allow
indexed assignment (subsasgn). cview would not interfere with the
reference counting mechanism,
while aview would - a mechanism would be needed to avoid sharing an
object that has assignable views.

Zero-based indexing (sometimes wanted, for instance in DSP) could be
simply achieved by overriding the lower bound when constructing a
view, as well as arbitrary-base indexing. It would be possible to take
a view of a view, in which case a subview would be created. Also, it
would be possible to replace a single dimension by multiple ones in a
view, making more index mappings possible. The viewed section in a
dimension would not need to be constrained to contiguous ranges;
ranges with steps or even index vectors could also be accepted.

I would like to inquire your opinions, criticisms or suggestions.

regards,

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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