Class ComplexSparseMatrixGetSet
java.lang.Object
org.flag4j.operations.sparse.coo.complex.ComplexSparseMatrixGetSet
This class contains methods for getting/setting elements and slices from/to a complex sparse matrix.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
copyValuesNotInSlice
(CooCMatrix src, List<CNumber> entries, List<Integer> rowIndices, List<Integer> colIndices, int[] rowRange, int[] colRange) Copies values in sparse matrix which do not fall in the specified row and column ranges.static CooCVector
getCol
(CooCMatrix src, int colIdx) Gets a specified column from this sparse matrix.static CooCVector
getCol
(CooCMatrix src, int colIdx, int start, int end) Gets a specified column range from this sparse matrix.static CooCVector
getRow
(CooCMatrix src, int rowIdx) Gets a specified row from this sparse matrix.static CooCVector
getRow
(CooCMatrix src, int rowIdx, int start, int end) Gets a specified row range from this sparse matrix.static CooCMatrix
getSlice
(CooCMatrix src, int rowStart, int rowEnd, int colStart, int colEnd) Gets a specified rectangular slice of a sparse matrix.private static boolean
inSlice
(int row, int col, int rowStart, int rowEnd, int colStart, int colEnd) Checks if an index is in the specified slice.static CNumber
matrixGet
(CooCMatrix src, int row, int col) Gets the specified element from a sparse matrix.static CooCMatrix
matrixSet
(CooCMatrix src, int row, int col, CNumber value) Sets the specified element from a sparse matrix.static CooCMatrix
setCol
(CooCMatrix src, int colIdx, double[] col) Sets a column of a sparse matrix to the entries of a dense array.static CooCMatrix
setCol
(CooCMatrix src, int colIdx, CooCVector col) Sets a column of a sparse matrix to the entries of a sparse vector.static CooCMatrix
setCol
(CooCMatrix src, int colIdx, CNumber[] col) Sets a column of a sparse matrix to the entries of a dense array.static CooCMatrix
setRow
(CooCMatrix src, int rowIdx, double[] row) Sets a specified row of a complex sparse matrix to the values of a dense array.static CooCMatrix
setRow
(CooCMatrix src, int rowIdx, CooCVector row) Sets a specified row of a complex sparse matrix to the values of a sparse vector.static CooCMatrix
setRow
(CooCMatrix src, int rowIdx, CNumber[] row) Sets a specified row of a complex sparse matrix to the values of a dense array.static CooCMatrix
setSlice
(CooCMatrix src, double[][] values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of a dense array.private static CooCMatrix
setSlice
(CooCMatrix src, double[] values, int numRows, int numCols, int[] sliceRows, int[] sliceCols, int row, int col) Sets a slice of a sparse matrix to values given in a 1d dense array.static CooCMatrix
setSlice
(CooCMatrix src, int[][] values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of a dense array.static CooCMatrix
setSlice
(CooCMatrix src, Double[][] values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of a dense array.static CooCMatrix
setSlice
(CooCMatrix src, Integer[][] values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of a dense array.static CooCMatrix
setSlice
(CooCMatrix src, Matrix values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of a dense matrix.static CooCMatrix
setSlice
(CooCMatrix src, CooCMatrix values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of another sparse matrix.static CooCMatrix
setSlice
(CooCMatrix src, CooMatrix values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of another sparse matrix.static CooCMatrix
setSlice
(CooCMatrix src, CNumber[][] values, int row, int col) Copies a sparse matrix and sets a slice of the sparse matrix to the entries of a dense array.private static CooCMatrix
setSlice
(CooCMatrix src, CNumber[] values, int numRows, int numCols, int[] sliceRows, int[] sliceCols, int row, int col) Sets a slice of a sparse matrix to values given in a 1d dense array.private static <T extends MatrixMixin<?,
?, ?, ?, ?, ?, ?, ?>>
voidsetSliceParamCheck
(T src, int valueRows, int valueCols, int row, int col) private static <T extends MatrixMixin<?,
?, ?, ?, ?, ?, ?, ?>, U extends MatrixMixin<?, ?, ?, ?, ?, ?, ?, ?>>
voidsetSliceParamCheck
(T src, U values, int row, int col)
-
Constructor Details
-
ComplexSparseMatrixGetSet
private ComplexSparseMatrixGetSet()
-
-
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 complex 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 entries of the row to set.- Returns:
- A copy of the
src
matrix with the specified row set to the denserow
array.
-
setRow
Sets a specified row of a complex 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 entries of the row to set.- Returns:
- A copy of the
src
matrix with the specified row set to the denserow
array.
-
setRow
Sets a specified row of a complex sparse matrix to the values of a sparse vector.- Parameters:
src
- Source matrix to set the row of.rowIdx
- Index of the row to set.row
- Dense array containing the entries 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 entries 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 entries 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 entries of a sparse vector.- 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 entries 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 entries 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 entries 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.
-
setSlice
Copies a sparse matrix and sets a slice of the sparse matrix to the entries 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 entries 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 entries 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 entries 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 entries 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
private static CooCMatrix setSlice(CooCMatrix src, double[] values, int numRows, int numCols, int[] sliceRows, int[] sliceCols, int row, int col) Sets a slice of a sparse matrix to values given in a 1d dense array.- Parameters:
src
- Source sparse matrix to copy non-slice from.values
- Dense value for slice.numRows
- Number of rows in the matrix represented byvalues
.numCols
- Number of columns in the matrix represented byvalues
.sliceRows
- Row indices for slice.sliceCols
- Column indices for slice.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 the specified values.
-
setSlice
private static CooCMatrix setSlice(CooCMatrix src, CNumber[] values, int numRows, int numCols, int[] sliceRows, int[] sliceCols, int row, int col) Sets a slice of a sparse matrix to values given in a 1d dense array.- Parameters:
src
- Source sparse matrix to copy non-slice from.values
- Dense value for slice.numRows
- Number of rows in the matrix represented byvalues
.numCols
- Number of columns in the matrix represented byvalues
.sliceRows
- Row indices for slice.sliceCols
- Column indices for slice.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 the specified values.
-
setSlice
Copies a sparse matrix and sets a slice of the sparse matrix to the entries 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 entries 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 entries 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
Gets a specified row from this sparse matrix.- Parameters:
src
- Source sparse matrix to extract row from.rowIdx
- Index of the row to extract from thesrc
matrix.- Returns:
- Returns the specified row from this sparse matrix.
-
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
Gets a specified column from this sparse matrix.- Parameters:
src
- Source sparse matrix to extract column from.colIdx
- Index of the column to extract from thesrc
matrix.- Returns:
- Returns the specified column from this sparse matrix.
-
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
public static CooCMatrix getSlice(CooCMatrix src, int rowStart, int rowEnd, int colStart, int colEnd) 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.
-
inSlice
private static boolean inSlice(int row, int col, int rowStart, int rowEnd, int colStart, int colEnd) Checks if an index is in the specified slice.- Parameters:
row
- Row index of value.col
- Column index of value.rowStart
- Starting row index of slice (inclusive).rowEnd
- Ending row index of slice (exclusive).colStart
- Starting column index of slice (inclusive).colEnd
- Ending column index of slice (exclusive).- Returns:
- True if the indices are in the slice. False otherwise.
-
copyValuesNotInSlice
private static void copyValuesNotInSlice(CooCMatrix src, List<CNumber> entries, List<Integer> rowIndices, List<Integer> colIndices, int[] rowRange, int[] colRange) Copies values in sparse matrix which do not fall in the specified row and column ranges.- Parameters:
src
- Source sparse matrix to copy from.entries
- Destination list to add copied values to.rowIndices
- Destination list to add copied row indices to.colIndices
- Destination list to add copied column indices to.rowRange
- List of row indices to NOT copy from.colRange
- List of column indices to NOT copy from.
-
setSliceParamCheck
private static <T extends MatrixMixin<?,?, void setSliceParamCheck?, ?, ?, ?, ?, ?>, U extends MatrixMixin<?, ?, ?, ?, ?, ?, ?, ?>> (T src, U values, int row, int col) -
setSliceParamCheck
private static <T extends MatrixMixin<?,?, void setSliceParamCheck?, ?, ?, ?, ?, ?>> (T src, int valueRows, int valueCols, int row, int col)
-