165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
# File 'lib/mgmg/poly.rb', line 165
def partial_derivative(variable)
case variable.to_s
when /\Ac/i
if @mat.col_size <= 1
self.class.new(Mat.new(1, 1, 0), 28, 0, 12, 12)
else
mat = Mat.new(@mat.row_size, @mat.col_size-1) do |i, j|
@mat.body[i][j+1] * (j+1)
end
self.class.new(mat, 28, 0, 12, 12)
end
when /\As/i
if @mat.row_size <= 1
self.class.new(Mat.new(1, 1, 0), 28, 0, 12, 12)
else
mat = Mat.new(@mat.row_size-1, @mat.col_size) do |i, j|
@mat.body[i+1][j] * (i+1)
end
self.class.new(mat, 28, 0, 12, 12)
end
else
raise ArgumentError, "the argument must be `s' or `c', not `#{variable}'"
end
end
|