@@ -309,77 +309,4 @@ type FormalLaurentSeries{Coefficients}
309
309
c
310
310
end
311
311
end
312
-
313
-
314
- # ##########
315
- # Sandbox #
316
- # ##########
317
-
318
- MaxSeriesSize= 10
319
- MaxRange = 50
320
- MatrixSize= 15
321
- TT= Int64
322
-
323
- (n1, n2, n3) = int (rand (3 )* MaxSeriesSize)
324
-
325
- X = FormalPowerSeries {TT} (int (rand (n1)* MaxRange))
326
- Y = FormalPowerSeries {TT} (int (rand (n2)* MaxRange))
327
- Z = FormalPowerSeries {TT} (int (rand (n3)* MaxRange))
328
-
329
- c = int (rand ()* MatrixSize) # Size of matrix representation to generate
330
-
331
- nzeros = int (rand ()* MaxSeriesSize)
332
- @assert X == trim (X)
333
- XX = deepcopy (X)
334
- for i= 1 : nzeros
335
- idx = int (rand ()* MaxRange)
336
- if ! has (XX. c, idx)
337
- XX. c[idx] = convert (TT, 0 )
338
- end
339
- end
340
- @assert trim (XX) == X
341
-
342
- # Test addition, p.15, (1.3-4)
343
- @assert X+ X == 2 X
344
- @assert X+ Y == Y+ X
345
- @assert MatrixForm (X+ Y,c) == MatrixForm (X,c)+ MatrixForm (Y,c)
346
-
347
- # Test subtraction, p.15, (1.3-4)
348
- @assert X- X == 0 X
349
- @assert X- Y == - (Y- X)
350
- @assert MatrixForm (X- Y,c) == MatrixForm (X,c)- MatrixForm (Y,c)
351
-
352
- # Test multiplication, p.15, (1.3-5)
353
- @assert X* Y == Y* X
354
- @assert MatrixForm (X* X,c) == MatrixForm (X,c)* MatrixForm (X,c)
355
- @assert MatrixForm (X* Y,c) == MatrixForm (X,c)* MatrixForm (Y,c)
356
- @assert MatrixForm (Y* X,c) == MatrixForm (Y,c)* MatrixForm (X,c)
357
- @assert MatrixForm (Y* Y,c) == MatrixForm (Y,c)* MatrixForm (Y,c)
358
-
359
- @assert X.* Y == Y.* X
360
-
361
- # The reciprocal series has associated matrix that is the matrix inverse
362
- # of the original series
363
- # Force reciprocal to exist
364
- X. c[0 ] = 1
365
- discrepancy = (norm (inv (float (MatrixForm (X,c)))[1 , :]' [:, 1 ] - tovector (reciprocal (X, c),[0 : c- 1 ])))
366
- if discrepancy > c* sqrt (eps ())
367
- error (@sprintf (" Error %f exceeds tolerance %f" , discrepancy, c* sqrt (eps ())))
368
- end
369
- # @assert norm(inv(float(MatrixForm(X,c)))[1, :]'[:, 1] - tovector(reciprocal(X, c),c)) < c*sqrt(eps())
370
-
371
- # Test differentiation
372
- XX = derivative (X)
373
- for (k, v) in XX. c
374
- k== 0 ? continue : true
375
- @assert X. c[k+ 1 ] == v/ (k+ 1 )
376
- end
377
-
378
- # Test product rule [H, Sec.1.4, p.19]
379
- @assert derivative (X* Y) == derivative (X)* Y + X* derivative (Y)
380
-
381
- # Test right distributive law of composition [H, Sec.1.6, p.38]
382
- @assert compose (X,Z)* compose (Y,Z) == compose (X* Y, Z)
383
312
384
- # Test chain rule [H, Sec.1.6, p.40]
385
- @assert derivative (compose (X,Y)) == compose (derivative (X),Y)* derivative (Y)
0 commit comments