@@ -378,18 +378,43 @@ contains
378
378
type(error_type), allocatable, intent(out) :: error
379
379
${t1}$ :: x(6) = [${t1}$ :: 0, 5, 15, 30, 50, 75]
380
380
${t1}$ :: A(1, 3) = reshape([${t1}$ :: 1, 3, 5], [1, 3])
381
+ ${t1}$ :: B(2) = [${t1}$ :: 1, 2]
381
382
383
+ #! rank-1 diff
382
384
call check(error, all_close(diff(x), [${t1}$ :: 5, 10, 15, 20, 25]), &
383
- "diff(x ) in test_diff_real_${k1}$ failed")
385
+ "diff(<rank-1> ) in test_diff_real_${k1}$ failed")
384
386
if (allocated(error)) return
385
-
387
+ call check(error, all_close(diff(x, n=0), x), &
388
+ "diff(<rank-1>, n=0) in test_diff_real_${k1}$ failed")
386
389
call check(error, all_close(diff(x, n=2), [${t1}$ :: 5, 5, 5, 5]), &
387
- "diff(x , n=2) in test_diff_real_${k1}$ failed")
390
+ "diff(<rank-1> , n=2) in test_diff_real_${k1}$ failed")
388
391
if (allocated(error)) return
389
392
393
+ call check(error, all_close(diff(x, prepend=[${t1}$ :: 1]), [${t1}$ :: -1, 5, 10, 15, 20, 25]), &
394
+ "diff(<rank-1>, prepend=[${t1}$ :: 1]) in test_diff_real_${k1}$ failed")
395
+ if (allocated(error)) return
396
+ call check(error, all_close(diff(x, append=[${t1}$ :: 1]), [${t1}$ :: 5, 10, 15, 20, 25, -74]), &
397
+ "diff(<rank-1>, append=[${t1}$ :: 1]) in test_diff_real_${k1}$ failed")
398
+ if (allocated(error)) return
399
+
400
+ #! rank-2 diff
401
+ call check(error, all_close(diff(reshape(A, [3,1]), n=1, dim=1), reshape([${t1}$ :: 2, 2], [2, 1])), &
402
+ "diff(<rank-2>, n=1, dim=1) in test_diff_real_${k1}$ failed")
403
+ if (allocated(error)) return
390
404
call check(error, all_close(diff(A, n=1, dim=2), reshape([${t1}$ :: 2, 2], [1, 2])), &
391
- "diff(x, n=1, dim=2) in test_diff_real_${k1}$ failed")
405
+ "diff(<rank-2>, n=1, dim=2) in test_diff_real_${k1}$ failed")
406
+ if (allocated(error)) return
407
+
408
+ call check(error, all_close(diff(A, n=1, dim=2, prepend=reshape([${t1}$ :: 1], [1, 1]), &
409
+ append=reshape([${t1}$ :: 2], [1, 1])), reshape([${t1}$ :: 0, 2, 2, -3], [1, 4])), &
410
+ "diff(<rank-2>, n=1, dim=2, prepend=reshape([${t1}$ :: 1], [1, 1]), &
411
+ &append=reshape([${t1}$ :: 2], [1, 1])) in test_diff_real_${k1}$ failed")
412
+ if (allocated(error)) return
413
+
414
+ #! size(B, dim) <= n
415
+ call check(error, size(diff(B, 2)), 0, "size(diff(B, 2)) in test_diff_real_${k1}$ failed")
392
416
if (allocated(error)) return
417
+ call check(error, size(diff(B, 3)), 0, "size(diff(B, 3)) in test_diff_real_${k1}$ failed")
393
418
394
419
end subroutine test_diff_real_${k1}$
395
420
#:endfor
@@ -399,19 +424,39 @@ contains
399
424
type(error_type), allocatable, intent(out) :: error
400
425
${t1}$ :: x(6) = [${t1}$ :: 0, 5, 15, 30, 50, 75]
401
426
${t1}$ :: A(1, 3) = reshape([${t1}$ :: 1, 3, 5], [1, 3])
427
+ ${t1}$ :: B(2) = [${t1}$ :: 1, 2]
402
428
429
+ #! rank-1 diff
403
430
call check(error, all(diff(x) == [${t1}$ :: 5, 10, 15, 20, 25]), &
404
- "diff(x) in test_diff_int_${k1}$ failed")
431
+ "diff(<rank-1>) in test_diff_int_${k1}$ failed")
432
+ if (allocated(error)) return
433
+ call check(error, all(diff(x, n=0) == x), &
434
+ "diff(<rank-1>, n=0) in test_diff_int_${k1}$ failed")
405
435
if (allocated(error)) return
406
-
407
436
call check(error, all(diff(x, n=2) == [${t1}$ :: 5, 5, 5, 5]), &
408
- "diff(x, n=2) in test_diff_int_${k1}$ failed")
437
+ "diff(<rank-1>, n=2) in test_diff_int_${k1}$ failed")
438
+ if (allocated(error)) return
439
+
440
+ call check(error, all(diff(x, prepend=[${t1}$ :: 1]) == [${t1}$ :: -1, 5, 10, 15, 20, 25]), &
441
+ "diff(<rank-1>, prepend=[${t1}$ :: 1]) in test_diff_int_${k1}$ failed")
442
+ if (allocated(error)) return
443
+ call check(error, all(diff(x, append=[${t1}$ :: 1]) == [${t1}$ :: 5, 10, 15, 20, 25, -74]), &
444
+ "diff(<rank-1>, append=[${t1}$ :: 1]) in test_diff_int_${k1}$ failed")
409
445
if (allocated(error)) return
410
446
447
+ #! rank-2 diff
448
+ call check(error, all(diff(reshape(A, [3,1]), n=1, dim=1) == reshape([${t1}$ :: 2, 2], [2, 1])), &
449
+ "diff(<rank-2>, n=1, dim=1) in test_diff_int_${k1}$ failed")
450
+ if (allocated(error)) return
411
451
call check(error, all(diff(A, n=1, dim=2) == reshape([${t1}$ :: 2, 2], [1, 2])), &
412
452
"diff(A, n=1, dim=2) in test_diff_int_${k1}$ failed")
413
453
if (allocated(error)) return
414
454
455
+ #! size(B, dim) <= n
456
+ call check(error, size(diff(B, 2)), 0, "size(diff(B, 2)) in test_diff_real_${k1}$ failed")
457
+ if (allocated(error)) return
458
+ call check(error, size(diff(B, 3)), 0, "size(diff(B, 3)) in test_diff_real_${k1}$ failed")
459
+
415
460
end subroutine test_diff_int_${k1}$
416
461
#:endfor
417
462
0 commit comments