How to use the amici.ode_export.csc_matrix function in amici

To help you get started, we’ve selected a few amici examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ICB-DCM / AMICI / tests / testMisc.py View on Github external
def test_csc_matrix(self):
        """Test sparse CSC matrix creation"""
        matrix = sp.Matrix([[1, 0], [2, 3]])
        symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix = \
            amici.ode_export.csc_matrix(matrix, 'a')

        assert symbolColPtrs == [0, 2, 3]
        assert symbolRowVals == [0, 1, 1]
        assert sparseList == sp.Matrix([[1], [2], [3]])
        assert symbolList == ['a0', 'a1', 'a2']
        assert str(sparseMatrix) == 'Matrix([[a0, 0], [a1, a2]])'
github ICB-DCM / AMICI / tests / testMisc.py View on Github external
def test_csc_matrix_vector(self):
        """Test sparse CSC matrix creation from matrix slice"""
        matrix = sp.Matrix([[1, 0], [2, 3]])
        symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix = \
            amici.ode_export.csc_matrix(matrix[:, 0], 'a')

        assert symbolColPtrs == [0, 2]
        assert symbolRowVals == [0, 1]
        assert sparseList == sp.Matrix([[1], [2]])
        assert symbolList == ['a0', 'a1']
        assert str(sparseMatrix) == 'Matrix([[a0], [a1]])'

        '''Test continuation of numbering of symbols'''
        symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix = \
            amici.ode_export.csc_matrix(matrix[:, 1], 'a',
                                        base_index=len(symbolList))

        assert symbolColPtrs == [0, 1]
        assert symbolRowVals == [1]
        assert sparseList == sp.Matrix([[3]])
        assert symbolList == ['a2']
github ICB-DCM / AMICI / tests / testMisc.py View on Github external
def test_csc_matrix_vector(self):
        """Test sparse CSC matrix creation from matrix slice"""
        matrix = sp.Matrix([[1, 0], [2, 3]])
        symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix = \
            amici.ode_export.csc_matrix(matrix[:, 0], 'a')

        assert symbolColPtrs == [0, 2]
        assert symbolRowVals == [0, 1]
        assert sparseList == sp.Matrix([[1], [2]])
        assert symbolList == ['a0', 'a1']
        assert str(sparseMatrix) == 'Matrix([[a0], [a1]])'

        '''Test continuation of numbering of symbols'''
        symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix = \
            amici.ode_export.csc_matrix(matrix[:, 1], 'a',
                                        base_index=len(symbolList))

        assert symbolColPtrs == [0, 1]
        assert symbolRowVals == [1]
        assert sparseList == sp.Matrix([[3]])
        assert symbolList == ['a2']
        assert str(sparseMatrix) == 'Matrix([[0], [a2]])'
github ICB-DCM / AMICI / tests / testMisc.py View on Github external
def test_csc_matrix_empty(self):
        """Test sparse CSC matrix creation for empty matrix"""
        matrix = sp.Matrix()
        symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix = \
            amici.ode_export.csc_matrix(matrix, 'a')
        print(symbolColPtrs, symbolRowVals, sparseList, symbolList, sparseMatrix)
        assert symbolColPtrs == []
        assert symbolRowVals == []
        assert sparseList == sp.Matrix(0, 0, [])
        assert symbolList == []
        assert str(sparseMatrix) == 'Matrix(0, 0, [])'