help-octave
[Top][All Lists]
Advanced

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

Efficient definition of multidimensional ranges


From: stn
Subject: Efficient definition of multidimensional ranges
Date: Tue, 29 May 2012 11:29:00 +0200





Hi,

this is about the definition of a number of sets of columns to be selected from a matrix and then process each set separately.

The dataset in question has around 300 columns an has to be reduced to a much smaller number of columns by adding the row-values in each predefined set of columns.

For my purposes it would be sufficient to generate a list of column-indexes to be output to stdout. Further processing is done by the surrounding shell-script and mysql-queries.

An obvious solution would be for example:
1:3,4:6,7:12,13:14

Simple enough. But

- in my case this list changes often

- The groups may or may not have equal sizes

- In the solution above each group has to be defined separately even if there are multiple groups of the same size. There is no obvious way to for example define "give me 3 groups of length 4 counting upwards from the previous group"

- there is no obvious way to account for the fact that the indexes count upwards through the groups so if you are not careful you may miss columns or assign columns to 2 groups

- This definition is meant to be passed from the surrounding shellscript so it should not really be an octave-program, rather a definition in the style of the usual range-definitions.

- the first column is not necessarily 1. The whole set can be shifted anywhere within the range of the 300 columns (of course the last column of the set is <300 )



So I think I am looking for a way to define multiple ranges. A simple range would be something like 1:10.

What I am looking for is a short systematic way to define something like:

1   2   3
4   5   6
7    8    9   10   11   12
13   14

the definition would be: 2 groups length 3, 1 group length 6, 1 group length 2, counting from 1 to last, (whatever last may be)

THX
stn


reply via email to

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