Class RealCooMatrixGetSet
java.lang.Object
org.flag4j.linalg.ops.sparse.coo.real.RealCooMatrixGetSet
This class provides methods for getting and setting elements and slices from/to a real sparse matrix.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CooVector
Gets a specified column from this sparse matrix.static CooVector
Gets a specified column range from this sparse matrix.static CooVector
Gets a specified row from this sparse matrix.static CooVector
Gets a specified row range from this sparse matrix.static CooMatrix
Gets a specified rectangular slice of a sparse matrix.static double
Gets the specified element from a sparse matrix.static CooMatrix
Sets the specified element from a sparse matrix.static CooMatrix
Sets a column of a sparse matrix to the data of a dense array.static CooMatrix
Sets a column of a sparse matrix to the values in a sparse tensor.static CooMatrix
Sets a specified row of a real sparse matrix to the values of a dense array.static CooMatrix
Sets a specified row of a real sparse COO matrix to the values in a sparse COO vector.static CooMatrix
Copies a sparse matrix and sets a slice of the sparse matrix to the data of a dense array.static CooMatrix
Copies a sparse matrix and sets a slice of the sparse matrix to the data of a dense array.static CooMatrix
Copies a sparse matrix and sets a slice of the sparse matrix to the data of a dense matrix.static CooMatrix
Copies a sparse matrix and sets a slice of the sparse matrix to the data of another sparse matrix.
-
Method Details
-
matrixGet
Gets the specified element from a sparse matrix.- Parameters:
src
- Source matrix to get value from.row
- Row index of the value to get from the sparse matrix.col
- Column index of the value to get from the sparse matrix.- Returns:
- The value in the sparse matrix at the specified indices.
-
matrixSet
Sets the specified element from a sparse matrix.- Parameters:
src
- Sparse matrix to set value in.row
- Row index of the value to set in the sparse matrix.col
- Column index of the value to set in the sparse matrix.value
- Value to set.- Returns:
- The
-
setRow
Sets a specified row of a real sparse COO matrix to the values in a sparse COO vector.- Parameters:
src
- Sparse COO matrix to set row in.rowIdx
- Index of the row to set.row
- Sparse COO vector containing new data for the row.- Returns:
- A new COO matrix resulting from setting row
rowIdx
insrc
torow
. - Throws:
IllegalArgumentException
- Ifrow.length != src.numCols
.
-
setRow
Sets a specified row of a real sparse matrix to the values of a dense array.- Parameters:
src
- Source matrix to set the row of.rowIdx
- Index of the row to set.row
- Dense array containing the data of the row to set.- Returns:
- A copy of the
src
matrix with the specified row set to the denserow
array.
-
setCol
Sets a column of a sparse matrix to the data of a dense array.- Parameters:
src
- Source matrix to set column of.colIdx
- The index of the column to set within thesrc
matrix.col
- The dense array containing the new column data for thesrc
array.- Returns:
- A copy of the
src
matrix with the specified column set to the dense array. - Throws:
IllegalArgumentException
- If thecolIdx
is not within the range of the matrix.IllegalArgumentException
- If thecol
array does not have the same length as the number of rows insrc
matrix.
-
setCol
Sets a column of a sparse matrix to the values in a sparse tensor.- Parameters:
src
- Source matrix to set column of.colIdx
- Index of the column to set.col
- New data for the specified column.- Returns:
- A copy of the
src
matrix with the specified column set to thecol
sparse vector. - Throws:
IllegalArgumentException
- If thesrc
matrix does not have the same number of rows as total data in thecol
vector.
-
setSlice
Copies a sparse matrix and sets a slice of the sparse matrix to the data of another sparse matrix.- Parameters:
src
- Source sparse matrix to copy and set values of.values
- Values of the slice to be set.row
- Starting row index of slice.col
- Starting column index of slice.- Returns:
- A copy of the
src
matrix with the specified slice set to thevalues
matrix. - Throws:
IllegalArgumentException
- If thevalues
matrix does not fit in thesrc
matrix given the row and column index.
-
setSlice
Copies a sparse matrix and sets a slice of the sparse matrix to the data of a dense array.- Parameters:
src
- Source sparse matrix to copy and set values of.values
- Dense values of the slice to be set.row
- Starting row index of slice.col
- Starting column index of slice.- Returns:
- A copy of the
src
matrix with the specified slice set to thevalues
array. - Throws:
IllegalArgumentException
- If thevalues
array does not fit in thesrc
matrix given the row and column index.
-
setSlice
Copies a sparse matrix and sets a slice of the sparse matrix to the data of a dense matrix.- Parameters:
src
- Source sparse matrix to copy and set values of.values
- Dense matrix containing values of the slice to be set.row
- Starting row index of slice.col
- Starting column index of slice.- Returns:
- A copy of the
src
matrix with the specified slice set to thevalues
array. - Throws:
IllegalArgumentException
- If thevalues
array does not fit in thesrc
matrix given the row and column index.
-
setSlice
Copies a sparse matrix and sets a slice of the sparse matrix to the data of a dense array.- Parameters:
src
- Source sparse matrix to copy and set values of.values
- Dense values of the slice to be set.row
- Starting row index of slice.col
- Starting column index of slice.- Returns:
- A copy of the
src
matrix with the specified slice set to thevalues
array. - Throws:
IllegalArgumentException
- If thevalues
array does not fit in thesrc
matrix given the row and column index.
-
getRow
-
getRow
Gets a specified row range from this sparse matrix.- Parameters:
src
- Source sparse matrix to extract row from.rowIdx
- Index of the row to extract from thesrc
matrix.start
- Staring column index of the column to be extracted (inclusive).end
- Ending column index of the column to be extracted (exclusive)- Returns:
- Returns the specified column range from this sparse matrix.
-
getCol
-
getCol
Gets a specified column range from this sparse matrix.- Parameters:
src
- Source sparse matrix to extract column from.colIdx
- Index of the column to extract from thesrc
matrix.start
- Staring row index of the column to be extracted (inclusive).end
- Ending row index of the column to be extracted (exclusive)- Returns:
- Returns the specified column range from this sparse matrix.
-
getSlice
Gets a specified rectangular slice of a sparse matrix.- Parameters:
src
- Sparse matrix to extract slice from.rowStart
- Starting row index of the slice (inclusive).rowEnd
- Ending row index of the slice (exclusive).colStart
- Staring column index of a slice (inclusive).colEnd
- Ending column index of the slice (exclusive).- Returns:
- The specified slice of the sparse matrix.
-