Search
Code Directory
 ASP
 ASP.NET
 C/C++
 CFML
 CGI/PERL
 Delphi
 Development
 Flash
 HTML
 Java
 JavaScript
 Pascal
 PHP
 Python
 SQL
 Tools
 Visual Basic & VB.NET
 XML
New Code
The C# Excel Library 2020.5
dbForge Studio for MySQL 9.0
LinkedIn Clone 2.2
Uber clone Apps 4.0
Cab Booking Script 1.3.2
Airbnb Clone HomestayDNN 3.0
Magento Language switcher 1.2.1
The .Net PDF Library 2020.3.2
IP2Location Geolocation Database 2020.5
ODBC Driver for MailChimp 2.0
ODBC Driver for NetSuite 2.0
ODBC Driver for SQL Azure 3.1
dbForge Schema Compare for Oracle 4.1
dbForge Data Compare for Oracle 5.1
dbForge Studio for Oracle 4.1
Top Code
dbForge Studio for MySQL 8.1
dbForge Studio for Oracle 3.10
dbForge Schema Compare for Oracle 2.7
dbForge Data Compare for Oracle 3.7
IP2Location Geolocation Database 2020.5
azar's knights tour 1.0
PDF Chart Creator DLL
PDF Chart Creator Dynamic Link Library 1.0
Form creator 1.0
FormMail Lite 1.0
SocketTimesheet
BS/1 Professional - Time Billing and Accounting
Online Video Rental Software System Alpha
Bullschmidt ASP Web Database Sample 2.0
Easy PCB Design Software in Java 1.0
Top Rated
phpEnter 5.1.
Single Leg MLM 1.2.1
Azizi search engine script PHP 4.1.10
Paste phpSoftPro 1.4.1
Extreme Injector 3.7
Deals and Discounts Website Script 1.0.2
Solid File System OS edition 5.1
Classified Ad Lister 1.0
Aglowsoft SQL Query Tools 8.2
Invoice Manager by PHPJabbers 3.0
ICPennyBid Penny Auction Script 4.0
PHP Review Script 1.0
ATN Resume Finder 2.0
ATN Site Builder 3.0
Availability Booking Calendar PHP 1.0
N-dimensional sparse arrays 1.0
File ID: 84017






N-dimensional sparse arrays 1.0
Download N-dimensional sparse arrays 1.0http://www.mathworks.comReport Error Link
License: Shareware
File Size: 20.5 KB
Downloads: 0
Submit Rating:
N-dimensional sparse arrays 1.0 Description
Description: 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.

License: Shareware

Related: Details, Usage, Browsing, ndsparsemethodname, shiftdim, flipdims, squeeze, operations, anyall

O/S:BSD, Linux, Solaris, Mac OS X

File Size: 20.5 KB

Downloads: 0



More Similar Code

I have looked far and wide for code for fast sorting of n dimensional arrays by the first element, for example if I had the array:
ray = [[1,2,3,7,5][10,11,12,13,14]]

I would want it to come out as
ray = [[1,2,3,5,7][10,11,12,14,13]]

There are several ways to do this. One is
zipped = zip(ray)
zipped.sort()
ray = zip(zipped)

but this is extremely slow. Numpy has...



Three ways to calculate a distance matrix out of a list of n-dimensional points using scipy.



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

A continuous function f(x1, x2, ... xN) is considered separable if there exist N functions f1, f2, ... fN...



Code to generate n-dimensional memory-mapped arrays for efficiently accessing large array datasets
Memory-mapped arrays reside within binary files, but are mapped to MATLAB's working memory. They are particularly useful when handling large...



HISTCND Histogram count for n dimensional data.
N = HISTCND(X,EDGES), for row vectors X, counts the number of values in
X that fall between the grid defined by the cell array of EDGES, each
of whose element is a vector that...



MAJLE (Weak) Majorization check
S = MAJLE(X,Y) checks if the real part of X is (weakly) majorized by the real part of Y, where X and Y must be numeric (full or sparse) arrays. It returns S=0, if there is no weak majorization of X by Y, S=1,...



This program computes the projection of any n-dimensional vector y onto the canonical simplex Dn defined by Dn:={x: x n-dimensional vector, 0



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. In these cases MATLAB FFT2 can result extremely inefficient. In general the...



This builds a navigation GUI for navigating n-dimensional convex Pareto surfaces interactively. It requires linprog from the
optimization toolbox, but can probably be replaced easily with a free version. The linear programs solved during...



function [i,i_] = fgridmin(y)
% Search an N-dimensional array y for points that may be proximate to a global minimum
% of the interpolated array; return the proximate points' N-D subscripts (i) in y. Also
% optionally return the...

User Review for N-dimensional sparse arrays
- required fields
     

Please enter text on the image