Skip to content

Dynamic sparse vector and matrix for julia

License

Notifications You must be signed in to change notification settings

atoptima/DynamicSparseArrays.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DynamicSparseArrays.jl

Documentation Build Status codecov Project Status: Active – The project has reached a stable, usable state and is being actively developed. License: MPL 2.0

Brief introduction to the package: https://atoptima.github.io/Coluna.jl/stable/dynamic_sparse_arrays/

Install the package :

] add DynamicSparseArrays

Example

using DynamicSparseArrays
I = [1, 10, 3, 5, 3]
V = [1.0, 2.4, 7.1, 1.1, 1.0]
vector = dynamicsparsevec(I,V) # create a vector

vector[3] == 2.4 + 1.0 # true
vector[78] = 1.5 # insert a value (new row)
vector[2] # retrieve a value
vector[2] = 0 # delete a value


I = [1, 2, 3, 2, 6, 7, 1, 6, 8] #rows
J = [1, 1, 1, 2, 2, 2, 3, 3, 3] #columns
V = [2, 3, 4, 2, 4, 5, 3, 5, 7] #value
matrix = dynamicsparse(I,J,V) # create a matrix

matrix[4,1] = 1 # new column
matrix[2,2] = 0 # delete value
deletecolumn!(matrix, 2) # delete column with id 2
matrix[2,6] == 0 # true