<commit_before>from railgun import SimObject, relpath

class LinearODE(SimObject):
    """
    Solve D-dimensional linear ordinary differential equations

    Equation::

        dX/dt(t) = A X(t)
        X: D-dimensional vector
        A: DxD matrix

    """

    _clibname_ = 'liblode.so'  # name of shared library
    _clibdir_ = relpath('.', __file__)  # library directory
    _cmembers_ = [  # declaring members of struct
        'num_d',  # num_* as size of array (no need to write `int`)
        'num_s = 10000',  # setting default value
        'double dt = 0.001',
        'double a[d][d]',  # num_d x num_d array
        'double x[s][d]',  # num_s x num_d array
        ]
    _cfuncs_ = [  # declaring functions to load
        "x run(s s_end=num_s)"
        # argument `s_end` has index `s` type and default is `num_s`
        # this function returns member x
        ]


def main():
    lode = LinearODE(num_d=2)  # set num_d
    lode.x[0] = [1, 0]  # access c-member via lode.VAR
    lode.a = [[0, 1], [-1, 0]]
    x = lode.run()

    import pylab
    pylab.subplot(211)
    pylab.plot(x[:,0])
    pylab.plot(x[:,1])
    pylab.subplot(212)
    pylab.plot(x[:,0], x[:,1])
    pylab.show()

<commit_msg>added ixt '<' to lode.py otherwise it fails<commit_after>from railgun import SimObject, relpath

class LinearODE(SimObject):
    """
    Solve D-dimensional linear ordinary differential equations

    Equation::

        dX/dt(t) = A X(t)
        X: D-dimensional vector
        A: DxD matrix

    """

    _clibname_ = 'liblode.so'  # name of shared library
    _clibdir_ = relpath('.', __file__)  # library directory
    _cmembers_ = [  # declaring members of struct
        'num_d',  # num_* as size of array (no need to write `int`)
        'num_s = 10000',  # setting default value
        'double dt = 0.001',
        'double a[d][d]',  # num_d x num_d array
        'double x[s][d]',  # num_s x num_d array
        ]
    _cfuncs_ = [  # declaring functions to load
        "x run(s< s_end=num_s)"
        # argument `s_end` has index `s` type and default is `num_s`
        # '<' means it is upper bound of the index so the range is [1, num_s]
        # this function returns member x
        ]


def main():
    lode = LinearODE(num_d=2)  # set num_d
    lode.x[0] = [1, 0]  # access c-member via lode.VAR
    lode.a = [[0, 1], [-1, 0]]
    x = lode.run()

    import pylab
    pylab.subplot(211)
    pylab.plot(x[:,0])
    pylab.plot(x[:,1])
    pylab.subplot(212)
    pylab.plot(x[:,0], x[:,1])
    pylab.show()


{'fraction_non_alphanumeric': 0.13322822230981474, 'fraction_numerical': 0.0216791486007095, 'mean_word_length': 2.3003901170351106, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5681184', 'n_tokens_mistral': 978, 'n_tokens_neox': 930, 'n_words': 264}