[orx-math] Make Matrix and SparseMatrix serializable with kotlinx.serialization
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.openrndr.extra.math.matrix
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Represents a two-dimensional matrix with support for basic operations such as indexing,
|
||||
* copying, and mathematical computations.
|
||||
@@ -7,6 +9,7 @@ package org.openrndr.extra.math.matrix
|
||||
* @property rows The number of rows in the matrix.
|
||||
* @property cols The number of columns in the matrix.
|
||||
*/
|
||||
@Serializable
|
||||
class Matrix(val rows: Int, val cols: Int) {
|
||||
val data = Array(rows) { DoubleArray(cols) }
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.openrndr.extra.math.matrix
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.sqrt
|
||||
|
||||
@@ -37,6 +38,7 @@ private fun countNonZeroElements(matrix: Matrix): Int {
|
||||
* @property columnIndices Array containing the column indices of the non-zero values.
|
||||
* @property rowPointers Array containing the starting position of each row in the values array.
|
||||
*/
|
||||
@Serializable
|
||||
class SparseMatrix(
|
||||
val rows: Int,
|
||||
val cols: Int,
|
||||
|
||||
Reference in New Issue
Block a user