17 from interval
import interval, inf
22 deg_to_rad = (math.pi/180.00)
23 rad_to_deg = (180.00/math.pi)
29 infinity = float(
"inf")
37 print "Error from sign_choice(): value z can not be zero"
52 elif abs(x - 1) < epsilon:
54 elif abs(x + 1) < epsilon:
63 B = numpy.zeros((n,m))
67 B[i,j] =
round(A[i,j])
70 def equal(v1,v2, epsilon = epsilon):
72 Returns 1 if two values v1 and v2 are equal otherwise returns 0
74 return (abs(v1-v2) < epsilon)
85 Returns 1 if x is positive, -1 if negative and 0 if abs(x) is smaller than epsilon
88 if (abs(x) < epsilon):
97 Sometimes the interval includes two descrite intervals so that
98 the upper bound of interval i equals the lower bound of interval i + 1
99 In this case it is better to connect the two intervals.
100 This functions does this and returns an interval in which all sequential continuous intervals are replaced by one interval.
108 for i
in range(1, nC):
113 R = R | interval([a,b])
117 R = R | interval([a,b])
122 This function returns "a" or "b" depending on the sign of "z",
123 if "z" is positive or zero, "a" is returned otherwise "b" is returned
132 solves the quadratic inequality "a*x^2 + b*x + c > 0" for "x"
133 and returns a feasibility set for "x" so that the inequality holds
137 sqrt_delta = math.sqrt(Delta)
138 x_l = (- b - sqrt_delta)/(2*a)
139 x_h = (- b + sqrt_delta)/(2*a)
141 return interval([-inf, x_l] , [x_h, inf])
143 return interval([x_l, x_h])
146 return interval([-inf, inf])
152 Returns the closest border of set S to value x. S is an interval variable from package interval
170 This function returns the interval in which x is located(accommodated)
171 if x is not in the interval, then None is returned
175 if (x >= xl)
and (x <= xh):
182 This function is translated from simulink model created by Gabriel
183 The .mdl file can be found in:
184 /home/nimasoft/Dropbox/software/matlab/packages/gabriell/Periodic_learning_v5_fafo_simulink/output_dyn_system_v4_simple.m
188 phi, r, h must be scalar values
189 c, W_arr must be arrays of minimum length N_w
199 print "W_arr[i] = ", W_arr[i]
202 print "num_in = ", num_in
204 num_in = num_in + psi*W_arr[i]*r
205 den_in = den_in + psi
207 return(num_in/den_in)
211 This function is translated from Matlab code written by Gabriel.
212 The Matlab code can be found in:
213 /home/nimasoft/Dropbox/software/matlab/packages/gabriell/Periodic_learning_v5_fafo_simulink/gauss_kernel_cosine.m
220 arg = math.cos(phi - c) - 1.0
221 psi = math.exp(h*arg)