@@ -405,4 +405,64 @@ program demo_math_is_close
405405 call check(all(is_close(x, [2.0, 2.0])), msg="all(is_close(x, [2.0, 2.0])) failed.", warn=.true.)
406406 !! all(is_close(x, [2.0, 2.0])) failed.
407407end program demo_math_is_close
408- ```
408+ ```
409+
410+ ### ` all_close `
411+
412+ #### Description
413+
414+ Returns a boolean scalar where two arrays are element-wise equal within a tolerance, behaves like ` all(is_close(a, b [, rel_tol, abs_tol])) ` .
415+
416+ #### Syntax
417+
418+ ` bool = [[stdlib_math(module):all_close(interface)]] (a, b [, rel_tol, abs_tol]) `
419+
420+ #### Status
421+
422+ Experimental.
423+
424+ #### Class
425+
426+ Impure function.
427+
428+ #### Arguments
429+
430+ ` a ` : Shall be a ` real/complex ` array.
431+ This argument is ` intent(in) ` .
432+
433+ ` b ` : Shall be a ` real/complex ` array.
434+ This argument is ` intent(in) ` .
435+
436+ ` rel_tol ` : Shall be a ` real ` scalar.
437+ This argument is ` intent(in) ` and ` optional ` , which is ` 1.0e-9 ` by default.
438+
439+ ` abs_tol ` : Shall be a ` real ` scalar.
440+ This argument is ` intent(in) ` and ` optional ` , which is ` 0.0 ` by default.
441+
442+ Note: All ` real/complex ` arguments must have same ` kind ` .
443+ If the value of ` rel_tol/abs_tol ` is negative (not recommended),
444+ it will be corrected to ` abs(rel_tol/abs_tol) ` by the internal process of ` all_close ` .
445+
446+ #### Result value
447+
448+ Returns a ` logical ` scalar.
449+
450+ #### Example
451+
452+ ``` fortran
453+ program demo_math_all_close
454+ use stdlib_math, only: all_close
455+ use stdlib_error, only: check
456+ real :: x(2) = [1, 2], random(4, 4)
457+ complex :: z(4, 4)
458+
459+ call check(all_close(x, [2.0, 2.0], rel_tol=1.0e-6, abs_tol=1.0e-3), &
460+ msg="all_close(x, [2.0, 2.0]) failed.", warn=.true.)
461+ !! all_close(x, [2.0, 2.0]) failed.
462+
463+ call random_number(random(4, 4))
464+ z = 1.0
465+ print *, all_close(z+1.0e-11*random, z) !! T
466+
467+ end program demo_math_all_close
468+ ```
0 commit comments