The module "multi2colblocks" of the Mastrave modelling library
Copyright and license notice of the function multi2colblocks
Copyright © 2009,2010,2011 Daniele de Rigo
The file multi2colblocks.m is part of Mastrave.
Mastrave is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Mastrave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Mastrave. If not, see http://www.gnu.org/licenses/.
Function declaration
[col_blocks, n_dims, n_points] = ... multi2colblocks( values , dims = [] , points = [] , in_orientation = 'columns' , out_orientation = 'columns' )
Description
Utility for extracting from a given dataset values (a matrix or multi-dimensional array) a sequence of subsets. values is intended to be a collection of N multidimensional points (or layers). If in_orientations has the default value, each column of values is intended to contain N values corresponding to a given coordinate of N points (or layers). From values , a sequence of blocks of coordinates - by default a sequence of sub-sets of columns - is to be aggregated in col_blocks . Each block is composed by the N points (or by the number of points indicated by points ) whose non-selected coordinates are replaced with zeros. In case values were a multidimensional array, the position of each coordinate dimension is equivalent to the position of the corresponding column in the matrix returned by multi2mat( values , in_orientation ).
Input arguments
values ::numeric:: Numeric vector, matrix or multidimensional-array. It is intended to be a collection of N multidimensional points (or layers): if in_orientations has the default value, each column of values is intended to contain N values corresponding to a given coordinate of N points (or layers). From values , a sequence of blocks of coordinates ─ by default a sequence of sub-sets of columns ─ is to be aggregated in col_blocks . Each block is composed by the N points (or by the number of points indicated by points ) whose non-selected coordinates are replaced with zeros. dims ::cellindex:: Cell-array of dimension sets (or just a single dimension set) the i-th of them lists which of the n dimensions of values (e.g. which of its n columns, if in_orientation has the default value) need to be preserved in the i-th block to be returned within col_blocks . In case values were a multidimensional array, the position of each coordinate dimension is equivalent to the position of the corresponding column in the matrix returned by multi2mat( values , in_orientation ). if dims is an empty matrix [], all dimensions will be separately included, so that [] is considered equivalent { 1, 2, ... , n }. If omitted, the default value is an empty matrix: []. points ::cellindex-1|numel:: Cell-array of indexes to the points of values (e.g. its rows, if in_orientation has the default value) to which each block element belongs. The i-th array of indexes of the cell-array points refers to the points of values to be included within the i-th block of col_blocks . The dimensions of these points which are listed in the i-th array of dims will be included in the i-th block of col_blocks . The values of the omitted dimensions of the points will be replaced with zeros. If a vector of non-negative numbers is passed instead of a cell-array, the i-th element of it is expected to indicate the number of points of values (starting from the first point) to be included in the i-th block of col_blocks . if points is an empty matrix [], all points will be included. If omitted, the default value is an empty matrix: []. in_orientation ::scalar_index|string:: Dimension along which to split values into blocks (default: 'columns'). Each colbloks column corresponds to a coordinate along the specified dimension of values . In case a string is passed, valid options are: option │ meaning ───────────────┼───────────────────────────────────── 'columns' │ Split values dimensions by │ considering them column-wise (each │ dimension corresponds to a column). │ Equivalent to 1. (Default value). ───────────────┼───────────────────────────────────── 'rows' │ Split values dimensions by │ considering them row-wise (each │ dimension corresponds to a row). │ Equivalent to 2. out_orientation ::scalar_index|string:: Dimension along which the blocks of values are to be packed in the sparse matrix col_blocks (default: 'columns'). In case a string is passed, valid options are: option │ meaning ───────────────┼───────────────────────────────────── 'columns' │ Pack values blocks so that each │ dimension corresponds to a column │ (column-wise). │ Equivalent to 1. (Default value). ───────────────┼───────────────────────────────────── 'rows' │ Pack values blocks so that each │ dimension corresponds to a row │ (row-wise). │ Equivalent to 2.
Example of usage
See also: multi2mat, mat2multi, cell2sparse, mdeal Keywords: multidimensional-array, smart reshape, column-wise, row-wise Version: 0.7.2
Support
The Mastrave modelling library is committed to provide reusable and general - but also robust and scalable - modules for research modellers dealing with computational science. You can help the Mastrave project by providing feedbacks on unexpected behaviours of this module. Despite all efforts, all of us - either developers or users - (should) know that errors are unavoidable. However, the free software paradigm successfully highlights that scientific knowledge freedom also implies an impressive opportunity for collectively evolve the tools and ideas upon which our daily work is based. Reporting a problem that you found using Mastrave may help the developer team to find a possible bug. Please, be aware that Mastrave is entirely based on voluntary efforts: in order for your help to be as effective as possible, please read carefully the section on reporting problems. Thank you for your collaboration.