<s> """<STR_LIT>""" <EOL> import timeit <EOL> import numpy as np <EOL> import sympy as sm <EOL> from pydy import models <EOL> from pydy . codegen . ode_function_generators import LambdifyODEFunctionGenerator <EOL> sys = models . n_link_pendulum_on_cart ( <NUM_LIT:3> , True , True ) <EOL> right_hand_side = sys . eom_method . rhs ( ) <EOL> constants = list ( sm . ordered ( sys . constants_symbols ) ) <EOL> specifieds = list ( sm . ordered ( sys . specifieds_symbols ) ) <EOL> constants_arg_types = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> specifieds_arg_types = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> p_array = np . array ( [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> p_dct = dict ( zip ( constants , p_array ) ) <EOL> p = { } <EOL> p [ '<STR_LIT>' ] = p_array <EOL> p [ '<STR_LIT>' ] = p_dct <EOL> r_array = np . array ( [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> r_dct_3 = { specifieds [ <NUM_LIT:0> ] : lambda x , t : np . ones ( <NUM_LIT:1> ) , <EOL> ( specifieds [ <NUM_LIT:3> ] , specifieds [ <NUM_LIT:1> ] ) : <EOL> lambda x , t : np . array ( [ <NUM_LIT> , <NUM_LIT> ] ) , <EOL> specifieds [ <NUM_LIT:2> ] : <NUM_LIT> * np . ones ( <NUM_LIT:1> ) } <EOL> r_func = lambda x , t : np . array ( [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> r = { } <EOL> r [ '<STR_LIT>' ] = r_array <EOL> r [ '<STR_LIT>' ] = r_dct_3 <EOL> r [ '<STR_LIT>' ] = r_func <EOL> x = np . array ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> itr = <NUM_LIT:1000> <EOL> print ( '<STR_LIT>' . format ( itr ) ) <EOL> for p_arg_type in constants_arg_types : <EOL> for r_arg_type in specifieds_arg_types : <EOL> g = LambdifyODEFunctionGenerator ( right_hand_side , <EOL> sys . coordinates , <EOL> sys . speeds , <EOL> constants , <EOL> specifieds = specifieds , <EOL> constants_arg_type = p_arg_type , <EOL> specifieds_arg_type = r_arg_type ) <EOL> rhs = g . generate ( ) <EOL> time = timeit . repeat ( "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> number = itr ) <EOL> print ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> . format ( p_arg = p_arg_type , r_arg = r_arg_type ) ) <EOL> print ( sum ( time ) / <NUM_LIT:3> ) </s>
