Home > By category > Scripts >Development Tools > N-dimensional sparse arrays

# N-dimensional sparse arrays

• Views:
• Rating:

The class ndSparse defined in this submission will give a lot of the functionality of N-dimensional sparse arrays for N possibly greater than 2. However, it should really be thought of as a way of starting with an ordinary MATLAB sparse matrix and reshaping it to have N dimensions. In other words, the sparse data must first be able to exist as an ordinary 2D MATLAB sparse matrix before being made N-dimensional. In fact, if the intended array has dimensions MxNxP...YxZ, then the class will store it internally as an ordinary 2D sparse array of dimensions (M*N*P*...*Y)xZ. This leads to certain performance limitations, but I still find that it has a reasonable range of use.

USAGE:

S=ndSparse(X) where X is an ordinary MATLAB sparse matrix converts X into an ndSparse object. S can be reshaped into an N-dimensional sparse array using its RESHAPE method, for arbitrary N.

S=ndSparse(X,[M,N,P,...]) is equivalent to reshape(ndSparse(X),[M,N,P,...]).

The class also has a variety of static methods that can be used to construct instances of the class. For example,

S=ndSparse.build(Coordinates,Values,[m,n,p,...],nzmax)

lets you generate an N-dimensional sparse array from a table of explicit entries. This is a generalization to N dimensions of S=sparse(i,j,s,m,n,nzmax).

Other such methods include:

ndSparse.accumarray
ndSparse.sprand
ndSparse.sprandn
ndSparse.spalloc

EXAMPLES:

>> A=ndSparse.build( [1 1 1; 2 1 1;2 2 2] , [50,60 70]) %Builds a 2x2x2 sparse array from table

A(:,:,1) =

(1,1) 50
(2,1) 60

A(:,:,2) =

(2,2) 70

Many of the same manipulations common to ordinary multidimensional MATLAB full arrays can be performed on the sparse 3D array A generated above. It can be permuted, summed, concatentated, and so forth e.g.,

>> B=sum( permute([A,A+10], [3,2,1]) ,2)

B(:,:,1) =

(1,1) 120
(2,1) 20

B(:,:,2) =

(1,1) 140
(2,1) 160

Other overloaded methods include BSXFUN, REPMAT, CIRCSHIFT, CONVN, FLIPDIMS, SQUEEZE, SHIFTDIM and many more. Type "methods ndSparse" for a full list and use "help ndSparse.methodname" to get details of usage.

When browsing the list of methods, note that certain common operations have different implementations, optimized for different situations. Specifically, SUM, ANY,ALL, MIN, MAX... have alternative implementations SUMML, ANYML, ALLML, MINML, MAXML which are optimized for "low-dimensional" ndSparse objects OBJ. Here, low-dimensional means that a normal N-column MATLAB sparse matrix won't consume too much memory on your platform for N=MAX(NUMEL(OBJ)./SIZE(OBJ)).

Another feature of the class is that bi-operand operations are allowed between ndSparse objects and MATLAB objects of any numeric type (single, uint16, etc...). This is not true of ordinary MATLAB sparse matrices, as of R2010b.

>> C=eye(2,'single')*B(:,:,2)

C =

(1,1) 140
(2,1) 160

>> whos A B C

Name Size Bytes Class Attributes

A 2x2x2 136 ndSparse
B 2x1x2 140 ndSparse
C 2x1 104 ndSparse

To convert back to an ordinary n-D full array, use the class' overloaded FULL method. To convert to a normal 2D sparse matrix, use the methods SPARSE or SPARSE2D. For example, SPARSE2D will convert an MxNxPx...xQ ndSparse array to the two dimensional (M*N*P*...)xQ sparse matrix in native MATLAB form.

Free download from Shareware Connection - The class ndSparse defined in this submission will give a lot of the functionality of N-dimensional sparse arrays for N possibly greater than 2

Publisher: Matt J | License: Shareware
Version: 1.0 | Size: 20 KB | Platform: Matlab, Scripts
Released Date: 20-01-2013 | Rating: 0 | Title: N-dimensional sparse arrays

Author Url: http://www.mathworks.com
Program Info Url: http://www.mathworks.com

Split nD-array into equal sized cells - MAT2TILES is basically a wrapper for mat2cell but with a more convenient interface when you are simply trying to decompose an N-dimensional array into equal-sized chunks.

Absolute Orientation - Horn's method - ABSOR - a tool for solving the absolute orientation problem using Horn's

Regular Control Point Interpolation Matrix with Boundary Conditions - The main file interpMatrix.m in this package creates a sparse Toeplitz-like matrix representing a regularly-spaced interpolation operation between a set of control points

3D Rotation about Shifted Axis - Generates the roto-translation matrix for the rotation around an arbitrary line in 3D.

Zero-Based Indexable Arrays (OOP Exercise) - I created this class of zero-indexable arrays purely as a fun OOP exercise, in reaction to various Newsgroup threads inquiring about zero-indexable matrix types for MATLAB

N-dimensional sparse arrays keywords:

N-dimensional Hypercubes - N-dimensional Hypercubes was developed as a small and simple tool that will help users learn more about will n-dimensional hypercube graphs.

Separable N-Dimensional Convolution - This function is an implementation of N-dimensional convolution for the special case when the convolution kernel is separable.

Snifflib - Snifflib is a Java based numerical library designed to provide honest-to-goodness N-dimensional array construction and manipulation along with standard linear algebra functionality as well as statistics and computational routines in the Java language

Easy memory-mapped arrays for large datasets - Code to generate n-dimensional memory-mapped arrays for efficiently accessing large array datasets

FFT2 optimization - Many image processing applications require an extensive usage of FFT2 routine (or, in the most general case, a N-dimensional FFT) of matrices having the same dimensions

Shareware Connection periodically updates pricing and software information of 'N-dimensional sparse arrays' from company source 'Matt J' , so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft,  Using 'N-dimensional sparse arrays' crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of N-dimensional sparse arrays.

New Reviews

TuckAway Intelligent Email Organizer Pro - Using an email software allow you to do a number of things including managing your address lists, emails and even ending memos, documents and even virtual letters. You can also use it to manage your tasks easily. The email software comes in ...

DataLocker SkyCrypt - Storing data in external hard drive is what any PC user can resort to but Cloud storage is gaining popularity with time. It gives you more flexibility and you can avail free and cheaply priced data storage in cloud as well. The only aspect that ...

LogmeOnce Password Manager Ultimate - Irrespective of your computer and web usage needs it is quite imperative that you will deal with passwords, in fact plenty of them. Both home and corporate network users need to log in to several web services and sites and for each of them, user ...

Auslogics BitReplica - With storage capacity and options going up with time, PC users have got numerous options to back up their important data, whether you need to store your music, movie collection or other types of data safely, using the PC’s HDD may not be ...

Magic Uneraser - Data loss can occur owing to a number of reasons, both within and beyond your control. Whether you have lost data owing to careless of another user or a hard drive failure has occurred, it is important to retrieve the data at any cost. There are ...

Protector Plus 2014 (32-bit) - Without using suitable security software in PC, you cannot have peace of mind nowadays. Increasing instances of malware attacks and attacking exploits have prompted average PC users to resort to using antivirus and security suites for both home ...

SyncMate - Just like windows users, Macintosh users also need to sync their data with myriads of other devices and other Macs. It is possible to use Apple’s much touted iCloud to sync a Mac with other iOS based devices but that may not fit ...

Perfect Photo Suite Premium Edition - For comprehensive image editing and web designing, millions of professionals use Adobe’s powerhouse and industry leading app, namely Photoshop. While Photoshop continues to be the darling of millions for advanced image retouching and ...

Cubase Artist - Professional audio editors and artists dealing in MIDI composition have a soft corner for Steinberg Cubase Artist. Its origin can be traced back to Atari ST and in later years, the app made way into PCs and Macs. The latest version is a flexible ...

Norton Zone - With a lot of your data being stored in some cloud service or other, it becomes necessary after a point to zero in on any one service rather than using many at the same time. As it is, major software companies are resorting to cloud based service ...

HR Management System

HR Management System,
developed by Ambit
Technologies Pvt. Ltd. is a
comprehensive Human Resource
Management System ...

ffdshow tryouts b3

ffdshow tryouts is a DS filter
and VFW codec for many audio
and video formats, such as
DivX, Xvid and H.264.

pentagonal tiling of the
Poincare Disc

pic shows recursion level of 7

mixed-integer LP

This function solves the mixed
integer linear programming
problems.

AtomatiCMS

AtomatiCMS is a simple-to-use
content management system that
caters for everyone; from
everyday users to web
developers.

Simulation for Ballistic
Deposition

This small program simulates
ballistic deposition for
surface growth

Apply affine transforms to
graphic objects

compared to hgtransform
objects is that it operates
directly on the XData

Phase and amplitude hue
plot

This routine was meant to be
used as a tool to represent
the a complex electric field
in a plane (with phase and
amplitude)

ANNI - solver of a set of
non-linear equations

Let us suppose a set of
non-linear equations in the
form F(m) = d (m,d are
vectors, F is a vector
function of vector ...

nextperm

Using lexical order on the set
{1, 2, ..., N}, outputs the
next permutation of the
ordered tuple x

XLS2STRUCT