Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multidimensional sparse matrices in Julia

Why aren't there any multidimensional sparse matrices/arrays in Julia? Why can we only have 2D sparse matrices and not for example 3D sparse matrices (or arrays)?

like image 252
12.yakir Avatar asked Feb 05 '14 23:02

12.yakir


People also ask

How do you find the dimensions of a matrix in Julia?

Get array dimensions and size of a dimension in Julia – size() Method. The size() is an inbuilt function in julia which is used to return a tuple containing the dimensions of the specified array. This returned tuple format is (a, b, c) where a is the rows, b is the columns and c is the height of the array.

How do you define matrices in Julia?

Julia provides a very simple notation to create matrices. A matrix can be created using the following notation: A = [1 2 3; 4 5 6]. Spaces separate entries in a row and semicolons separate rows. We can also get the size of a matrix using size(A).

How do you create an Array in Julia?

A 1D array can be created by simply writing array elements within square brackets separated by commas(, ) or semicolon(;). A 2D array can be created by writing a set of elements without commas and then separating that set with another set of values by a semicolon.

How do I add a row to a matrix in Julia?

A 2d Array is inherently a bad data structure if you want to add rows dynamically. Julia arrays are stored column-major (contiguous columns), which means that even if you resized the memory to accommodate a new row, you would need to insert a new element into each column by moving every column in memory.

What is the format of sparse matrix in Julia?

In Julia, sparse matrices are stored in the Compressed Sparse Column (CSC) format. Julia sparse matrices have the type SparseMatrixCSC{Tv,Ti}, where Tvis the type of the stored values, and Tiis the integer type for storing column pointers and row indices.:

What are matrices in Julia?

Matrices in Julia are the heterogeneous type of containers and hence, they can hold elements of any data type. It is not mandatory to define the data type of a matrix before assigning the elements to the matrix. Julia automatically decides the data type of the matrix by analyzing the values assigned to it.

What is a sparse array in Julia?

Sparse Arrays Julia has support for sparse vectors and sparse matrices in the SparseArrays stdlib module. Sparse arrays are arrays that contain enough zeros that storing them in a special data structure leads to savings in space and execution time, compared to dense arrays. Compressed Sparse Column (CSC) Sparse Matrix Storage

Does Julia support multi-dimensional arrays?

Multi-dimensional Arrays Julia, like most technical computing languages, provides a first-class array implementation. Most technical computing languages pay a lot of attention to their array implementation at the expense of other containers. Julia does not treat arrays in any special way.


1 Answers

The problem as I understand it (I'm not sparse linear algebra expert, although Viral Shah, who is one of the other Julia co-founders is) is that all libraries (e.g. SuiteSparse) for doing sparse computations are matrix-only. They don't support sparse vectors and they don't support higher dimensional tensors either. So we could define types for higher-dimensional sparse tensors, but you wouldn't be able to do anything useful with them.

like image 103
StefanKarpinski Avatar answered Oct 21 '22 15:10

StefanKarpinski