Octopus
math.F90
Go to the documentation of this file.
1!! Copyright (C) 2002-2006 M. Marques, A. Castro, A. Rubio, G. Bertsch
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
22module math_oct_m
23 use debug_oct_m
24 use global_oct_m
26 use, intrinsic :: iso_fortran_env
31
32 implicit none
33
34 private
35 public :: &
36 is_close, &
38 ylmr_cmplx, &
39 ylmr_real, &
40 weights, &
41 factorial, &
42 hermite, &
47 ddelta, &
48 member, &
52 even, &
53 odd, &
57 pad, &
58 pad_pow2, &
59 log2, &
61 phi1, &
62 phi2, &
64 is_prime, &
76
77 interface is_close
78 module procedure dis_close_scalar, zis_close_scalar
79 end interface
80
81 interface diagonal_matrix
83 end interface diagonal_matrix
84
88
92
95 interface interpolate
98 end interface interpolate
99
100 interface symmetrize_matrix
101 module procedure dsymmetrize_matrix
102 end interface symmetrize_matrix
103
104 interface log2
105 module procedure dlog2, ilog2, llog2
106 end interface log2
107
108 interface pad
109 module procedure pad4, pad8, pad48, pad88
110 end interface pad
111
112contains
113
132 elemental logical function dis_close_scalar(x, y, rtol, atol)
133 real(real64), intent(in) :: x, y
134 real(real64), optional, intent(in) :: rtol
135 real(real64), optional, intent(in) :: atol
136 real(real64) :: atol_, rtol_
137
138 atol_ = optional_default(atol, 1.e-8_real64)
139 rtol_ = optional_default(rtol, 1.e-5_real64)
140
141 dis_close_scalar = abs(x - y) <= (atol_ + rtol_ * abs(y))
142 end function dis_close_scalar
143
145 elemental logical function zis_close_scalar(x, y, rtol, atol)
146 complex(real64), intent(in) :: x, y
147 real(real64), optional, intent(in) :: rtol
148 real(real64), optional, intent(in) :: atol
149 real(real64) :: atol_, rtol_
150
151 atol_ = optional_default(atol, 1.e-8_real64)
152 rtol_ = optional_default(rtol, 1.e-5_real64)
153
154 zis_close_scalar = abs(x - y) <= (atol_ + rtol_ * abs(y))
155 end function zis_close_scalar
156
157
158 ! ---------------------------------------------------------
161 pure function idiagonal_matrix(dim, diag) result(matrix)
162 integer, intent(in) :: dim
163 integer, intent(in) :: diag
164 integer :: matrix(dim, dim)
165
166 integer :: ii
167
168 matrix = 0
169 do ii = 1, dim
170 matrix(ii, ii) = diag
171 end do
172
173 end function idiagonal_matrix
175 ! ---------------------------------------------------------
176 recursive function hermite(n, x) result (h)
177 integer, intent(in) :: n
178 real(real64), intent(in) :: x
179
180 real(real64) :: h
181
182 ! no push_sub, called too frequently
183
184 if (n <= 0) then
185 h = m_one
186 elseif (n == 1) then
187 h = m_two*x
188 else
189 h = m_two*x*hermite(n-1,x) - m_two*(n-1)*hermite(n-2,x)
190 end if
191
192 end function hermite
194
195 ! ---------------------------------------------------------
196 recursive function factorial (n) RESULT (fac)
197 integer, intent(in) :: n
198
199 integer :: fac
200
201 ! no push_sub for recursive function
202
203 if (n <= 1) then
204 fac = 1
205 else
206 fac = n * factorial(n-1)
207 end if
208 end function factorial
209
210 ! ---------------------------------------------------------
212 subroutine ylmr_cmplx(xx, li, mi, ylm)
213 real(real64), intent(in) :: xx(3)
214 integer, intent(in) :: li, mi
215 complex(real64), intent(out) :: ylm
216
217 integer :: i
218 real(real64) :: dx, dy, dz, r, plm, cosm, sinm, cosmm1, sinmm1, cosphi, sinphi
219 real(real64), parameter :: tiny = 1.e-15_real64
220
221 ! no push_sub: this routine is called too many times
222
223 ! if l=0, no calculations are required
224 if (li == 0) then
225 ylm = cmplx(sqrt(m_one/(m_four*m_pi)), m_zero, real64)
226 return
227 end if
228
229 r = sqrt(xx(1)**2 + xx(2)**2 + xx(3)**2)
230
231 ! if r=0, direction is undefined => make ylm=0 except for l=0
232 if (r <= tiny) then
233 ylm = m_z0
234 return
235 end if
236 dx = xx(1)/r
237 dy = xx(2)/r
238 dz = xx(3)/r
239
240 ! get the associated Legendre polynomial (including the normalization factor)
241 ! We need to avoid getting outside [-1:1] due to rounding errors
242 if(abs(dz) > m_one) dz = sign(m_one, dz)
243 plm = loct_legendre_sphplm(li, abs(mi), dz)
244
245 ! compute sin(|m|*phi) and cos(|m|*phi)
246 r = sqrt(dx*dx + dy*dy)
247 if(r > tiny) then
248 cosphi = dx/r
249 sinphi = dy/r
250 else ! In this case the values are ill defined so we choose \phi=0
251 cosphi = m_zero
252 sinphi = m_zero
253 end if
255 cosm = m_one
256 sinm = m_zero
257 do i = 1, abs(mi)
258 cosmm1 = cosm
259 sinmm1 = sinm
260 cosm = cosmm1*cosphi - sinmm1*sinphi
261 sinm = cosmm1*sinphi + sinmm1*cosphi
262 end do
263
264 !And now ylm
265 ylm = plm*cmplx(cosm, sinm, real64)
266
267 if (mi < 0) then
268 ylm = conjg(ylm)
269 do i = 1, abs(mi)
270 ylm = -ylm
271 end do
272 end if
273
274 end subroutine ylmr_cmplx
275
276
277 ! ---------------------------------------------------------
283 subroutine ylmr_real(xx, li, mi, ylm)
284 real(real64), intent(in) :: xx(3)
285 integer, intent(in) :: li, mi
286 real(real64), intent(out) :: ylm
287
288 integer, parameter :: lmaxd = 20
289 real(real64), parameter :: tiny = 1.e-15_real64
290 integer :: i, ilm0, l, m, mabs
291 integer, save :: lmax = -1
292
293 real(real64) :: cmi, cosm, cosmm1, cosphi, dphase, dplg, fac, &
294 fourpi, plgndr, phase, pll, pmm, pmmp1, sinm, &
295 sinmm1, sinphi, rsize, rx, ry, rz, xysize
296 real(real64), save :: c(0:(lmaxd+1)*(lmaxd+1))
297
298 ! no push_sub: called too frequently
299
300 ! evaluate normalization constants once and for all
301 if (li > lmax) then
302 fourpi = m_four*m_pi
303 do l = 0, li
304 ilm0 = l*l + l
305 do m = 0, l
306 fac = (2*l+1)/fourpi
307 do i = l - m + 1, l + m
308 fac = fac/i
309 end do
310 c(ilm0 + m) = sqrt(fac)
311 ! next line because ylm are real combinations of m and -m
312 if (m /= 0) c(ilm0 + m) = c(ilm0 + m)*sqrt(m_two)
313 c(ilm0 - m) = c(ilm0 + m)
314 end do
315 end do
316 lmax = li
317 end if
318
319 ! if l=0, no calculations are required
320 if (li == 0) then
321 ylm = c(0)
322 return
323 end if
324
325 ! if r=0, direction is undefined => make ylm=0 except for l=0
326 rsize = sqrt(xx(1)**2 + xx(2)**2 + xx(3)**2)
327 if (rsize < tiny) then
328 ylm = m_zero
329 return
330 end if
331
332 rx = xx(1)/rsize
333 ry = xx(2)/rsize
334 rz = xx(3)/rsize
335
336 ! explicit formulas for l=1 and l=2
337 if (li == 1) then
338 select case (mi)
339 case (-1)
340 ylm = (-c(1))*ry
341 case (0)
342 ylm = c(2)*rz
343 case (1)
344 ylm = (-c(3))*rx
345 end select
346 return
347 end if
348
349 if (li == 2) then
350 select case (mi)
351 case (-2)
352 ylm = c(4)*6.0_real64*rx*ry
353 case (-1)
354 ylm = (-c(5))*m_three*ry*rz
355 case (0)
356 ylm = c(6)*m_half*(m_three*rz*rz - m_one)
357 case (1)
358 ylm = (-c(7))*m_three*rx*rz
359 case (2)
360 ylm = c(8)*m_three*(rx*rx - ry*ry)
361 end select
362 return
363 end if
364
365 ! general algorithm based on routine plgndr of numerical recipes
366 mabs = abs(mi)
367 xysize = sqrt(max(rx*rx + ry*ry, tiny))
368 cosphi = rx/xysize
369 sinphi = ry/xysize
370 cosm = m_one
371 sinm = m_zero
372 do m = 1, mabs
373 cosmm1 = cosm
374 sinmm1 = sinm
375 cosm = cosmm1*cosphi - sinmm1*sinphi
376 sinm = cosmm1*sinphi + sinmm1*cosphi
377 end do
378
379 if (mi < 0) then
380 phase = sinm
381 dphase = mabs*cosm
382 else
383 phase = cosm
384 dphase = (-mabs)*sinm
385 end if
386
387 pmm = m_one
388 fac = m_one
389
390 if (mabs > m_zero) then
391 do i = 1, mabs
392 pmm = (-pmm)*fac*xysize
393 fac = fac + m_two
394 end do
395 end if
396
397 if (li == mabs) then
398 plgndr = pmm
399 dplg = (-li)*rz*pmm/(xysize**2)
400 else
401 pmmp1 = rz*(2*mabs + 1)*pmm
402 if (li == mabs + 1) then
403 plgndr = pmmp1
404 dplg = -((li*rz*pmmp1 - (mabs + li)*pmm)/(xysize**2))
405 else
406 do l = mabs + 2, li
407 pll = (rz*(2*l - 1)*pmmp1 - (l + mabs - 1)*pmm)/(l - mabs)
408 pmm = pmmp1
409 pmmp1 = pll
410 end do
411 plgndr = pll
412 dplg = -((li*rz*pll - (l + mabs - 1)*pmm)/(xysize**2))
413 end if
414 end if
415
416 ilm0 = li*li + li
417 cmi = c(ilm0 + mi)
418 ylm = cmi*plgndr*phase
419
420 end subroutine ylmr_real
421
422
423 ! ---------------------------------------------------------
433 subroutine weights(N, M, cc, side)
434 integer, intent(in) :: n, m
435 real(real64), intent(out) :: cc(0:,0:,0:)
436 integer, optional, intent(in) :: side
437
438 integer :: i, j, k, mn, side_
439 real(real64) :: c1, c2, c3, c4, c5, xi
440 real(real64), allocatable :: x(:)
441
442 push_sub(weights)
443
444 safe_allocate(x(0:m))
445
446 if (present(side)) then
447 side_ = side
448 else
449 side_ = 0
450 end if
451
452 select case (side_)
453 case (-1)
454 ! grid-points for left-side finite-difference formulas on an equi-spaced grid
455 mn = m
456 x(:) = (/(-i,i=0,mn)/)
457 case (+1)
458 ! grid-points for right-side finite-difference formulas on an equi-spaced grid
459 mn = m
460 x(:) = (/(i,i=0,mn)/)
461 case default
462 ! grid-points for centered finite-difference formulas on an equi-spaced grid
463 mn = m/2
464 x(:) = (/0,(-i,i,i=1,mn)/)
465 end select
466
467
468
469 xi = m_zero ! point at which the approx. are to be accurate
470
471 cc = m_zero
472 cc(0,0,0) = m_one
473
474 c1 = m_one
475 c4 = x(0) - xi
476
477 do j = 1, m
478 mn = min(j,n)
479 c2 = m_one
480 c5 = c4
481 c4 = x(j) - xi
482
483 do k = 0, j - 1
484 c3 = x(j) - x(k)
485 c2 = c2*c3
486
487 if (j <= n) cc(k, j - 1, j) = m_zero
488 cc(k, j, 0) = c4*cc(k, j - 1, 0)/c3
489
490 do i = 1, mn
491 cc(k, j, i) = (c4*cc(k, j - 1, i) - i*cc(k, j - 1, i - 1))/c3
492 end do
493
494 cc(j, j, 0) = -c1*c5*cc(j - 1, j - 1, 0) / c2
495 end do
496
497 do i = 1, mn
498 cc(j, j, i) = c1*(i*cc(j - 1, j - 1, i - 1) - c5*cc(j - 1, j - 1, i))/c2
499 end do
500
501 c1 = c2
502 end do
503
504 safe_deallocate_a(x)
505 pop_sub(weights)
506 end subroutine weights
507
508 ! ---------------------------------------------------------
509 real(real64) pure function ddelta(i, j)
510 integer, intent(in) :: i
511 integer, intent(in) :: j
512
513 ! no push_sub in pure function
514
515 if (i == j) then
516 ddelta = m_one
517 else
518 ddelta = m_zero
519 end if
520
521 end function ddelta
522
523
524 ! ---------------------------------------------------------
527 subroutine make_idx_set(n, out, length, in)
528 integer, intent(in) :: n
529 integer, allocatable, intent(out) :: out(:)
530 integer, intent(out) :: length
531 integer, optional, intent(in) :: in(:)
532
533 integer :: i
534
535 push_sub(make_idx_set)
536
537 if (present(in)) then
538 length = ubound(in, 1)
539 safe_allocate(out(1:length))
540 out(:) = in(:)
541 else
542 length = n
543 safe_allocate(out(1:length))
544 do i = 1, length
545 out(i) = i
546 end do
547 end if
548
549 pop_sub(make_idx_set)
550 end subroutine make_idx_set
551
552
553 ! ---------------------------------------------------------
556 logical function member(n, a)
557 integer, intent(in) :: n
558 integer, intent(in) :: a(:)
559
560 integer :: i
561
562 ! no push_sub, called too frequently
563
564 member = .false.
565
566 do i = 1, ubound(a, 1)
567 if (a(i) == n) then
568 member = .true.
569 exit
570 end if
571 end do
572
573 end function member
574
575
576 ! ---------------------------------------------------------
577 subroutine interpolation_coefficients(nn, xa, xx, cc)
578 integer, intent(in) :: nn
579 real(real64), intent(in) :: xa(:)
580 real(real64), intent(in) :: xx
581 real(real64), intent(out) :: cc(:)
582
583 integer :: ii, kk
584
585 ! no push_sub, called too frequently
586
587 do ii = 1, nn
588 cc(ii) = m_one
589 do kk = 1, nn
590 if (kk == ii) cycle
591 cc(ii) = cc(ii)*(xx - xa(kk))/(xa(ii) - xa(kk))
592 end do
593 end do
594
595 end subroutine interpolation_coefficients
596
597
598 ! ---------------------------------------------------------
600 logical pure function even(n)
601 integer, intent(in) :: n
603 even = (mod(n, 2) == 0)
604
605 end function even
606
607
608 ! ---------------------------------------------------------
610 logical pure function odd(n)
611 integer, intent(in) :: n
612
613 odd = .not. even(n)
614
615 end function odd
616
617 ! ---------------------------------------------------------
621 real(real64), intent(in) :: x(:)
622 real(real64), intent(out) :: u(:)
623
624 integer :: n, k, j
625 real(real64) :: sumx2
626 real(real64), allocatable :: xx(:)
627
629
630 n = size(x)
631 assert(n>1)
632 assert(size(u) == n-1)
633
634 ! These lines make the code less machine-dependent.
635 safe_allocate(xx(1:n))
636 do j = 1, n
637 if (abs(x(j))<1.0e-8_real64) then
638 xx(j) = m_zero
639 else
640 xx(j) = x(j)
641 end if
642 end do
643
644 u = m_zero
645 do k = 1, n-1
646 sumx2 = m_zero
647 do j = k+1, n
648 sumx2 = sumx2 + xx(j)**2
649 end do
650 if (abs(sumx2) <= m_epsilon .and. abs(xx(k)) <= m_epsilon) exit
651 if (k < n - 1) then
652 u(k) = atan2(sqrt(sumx2), xx(k))
653 else
654 u(n-1) = atan2(xx(n), xx(n-1))
655 end if
656 end do
657
658
660 end subroutine cartesian2hyperspherical
661 ! ---------------------------------------------------------
662
663
664 ! ---------------------------------------------------------
667 subroutine hyperspherical2cartesian(u, x)
668 real(real64), intent(in) :: u(:)
669 real(real64), intent(out) :: x(:)
671 integer :: n, j, k
672
674
675 n = size(x)
676 assert(n>1)
677 assert(size(u) == n-1)
678
679 if (n == 2) then
680 x(1) = cos(u(1))
681 x(2) = sin(u(1))
682 elseif (n == 3) then
683 x(1) = cos(u(1))
684 x(2) = sin(u(1))*cos(u(2))
685 x(3) = sin(u(1))*sin(u(2))
686 else
687 x(1) = cos(u(1))
688 x(2) = sin(u(1))*cos(u(2))
689 x(3) = sin(u(1))*sin(u(2))*cos(u(3))
690 do j = 4, n - 1
691 x(j) = m_one
692 do k = 1, j - 1
693 x(j) = x(j) * sin(u(k))
694 end do
695 x(j) = x(j) * cos(u(j))
696 end do
697 x(n) = m_one
698 do k = 1, n - 2
699 x(n) = x(n) * sin(u(k))
700 end do
701 x(n) = x(n) * sin(u(n-1))
702 end if
705 end subroutine hyperspherical2cartesian
706 ! ---------------------------------------------------------
707
708
709 ! ---------------------------------------------------------
713 subroutine hypersphere_grad_matrix(grad_matrix, r, x)
714 real(real64), intent(out) :: grad_matrix(:,:)
715 real(real64), intent(in) :: r
716 real(real64), intent(in) :: x(:)
717
718 integer :: n, l, m
719
721
722 n = size(x)+1 ! the dimension of the matrix is (n-1)x(n)
723
724 ! --- l=1 ---
725 grad_matrix = m_one
726 grad_matrix(1,1) = -r*sin(x(1))
727 do m = 2, n-1
728 grad_matrix(m,1) = m_zero
729 end do
730
731 ! --- l=2..(n-1) ---
732 do l=2, n-1
733 do m=1, n-1
734 if (m == l) then
735 grad_matrix(m,l) = -r*grad_matrix(m,l)*product(sin(x(1:l)))
736 elseif (m < l) then
737 grad_matrix(m,l) = grad_matrix(m,l)*r*cos(x(m))*cos(x(l))*product(sin(x(1:m-1)))*product(sin(x(m+1:l-1)))
738 else
739 grad_matrix(m,l) = m_zero
740 end if
741 end do
742 end do
743
744 ! --- l=n ---
745 do m=1, n-1
746 grad_matrix(m,n) = r*cos(x(m))*grad_matrix(m,n)*product(sin(x(1:m-1)))*product(sin(x(m+1:n-1)))
747 end do
748
750 end subroutine hypersphere_grad_matrix
751
752 ! ---------------------------------------------------------
753 integer(int64) pure function pad88(size, blk)
754 integer(int64), intent(in) :: size
755 integer(int64), intent(in) :: blk
756
757 integer(int64) :: mm
758
759 mm = mod(size, blk)
760 if (mm == 0) then
761 pad88 = size
762 else
763 pad88 = size + blk - mm
764 end if
765 end function pad88
766
767 ! ---------------------------------------------------------
768 integer(int64) pure function pad48(size, blk)
769 integer, intent(in) :: size
770 integer(int64), intent(in) :: blk
771
772 pad48 = pad88(int(size, int64), blk)
773 end function pad48
774
775 ! ---------------------------------------------------------
776 integer(int64) pure function pad8(size, blk)
777 integer(int64), intent(in) :: size
778 integer, intent(in) :: blk
779
780 pad8 = pad88(size, int(blk, int64))
781 end function pad8
782
783 ! ---------------------------------------------------------
784 integer pure function pad4(size, blk)
785 integer, intent(in) :: size
786 integer, intent(in) :: blk
787
788 pad4 = int(pad88(int(size, int64), int(blk, int64)), int32)
789 end function pad4
790
791 ! ---------------------------------------------------------
792
797 integer pure function pad_pow2(size)
798 integer, intent(in) :: size
799
800 integer :: mm, mm2
801
802 mm = size
803 pad_pow2 = 1
804
805 ! loop below never terminates otherwise! just pick 1 as value.
806 if (size == 0) return
807
808 ! first we divide by two all the times we can, so we catch exactly
809 ! the case when size is already a power of two
810 do
811 mm2 = mm/2
812 if (mm - 2*mm2 /= 0) exit
814 mm = mm2
815 end do
816
817 ! the rest is handled by log2
818 if (mm /= 1) then
819 pad_pow2 = pad_pow2*2**(ceiling(log(real(mm, real64) )/log(2.0_8)))
820 end if
821
822 end function pad_pow2
823
824 ! -------------------------------------------------------
825
826 real(real64) pure function dlog2(xx)
827 real(real64), intent(in) :: xx
828
829 dlog2 = log(xx)/log(m_two)
830 end function dlog2
831
832 ! -------------------------------------------------------
833
834 integer pure function ilog2(xx)
835 integer, intent(in) :: xx
836
837 ilog2 = nint(log2(real(xx, real64) ))
838 end function ilog2
839
840 ! -------------------------------------------------------
841
842 integer(int64) pure function llog2(xx)
843 integer(int64), intent(in) :: xx
844
845 llog2 = nint(log2(real(xx, real64) ), kind=int64)
846 end function llog2
847
848 ! -------------------------------------------------------
850 complex(real64) pure function exponential(z)
851 complex(real64), intent(in) :: z
852
853 exponential = exp(z)
854 end function exponential
855
856 ! -------------------------------------------------------
862 complex(real64) pure function phi1(z)
863 complex(real64), intent(in) :: z
864
865 real(real64), parameter :: cut = 0.002_real64
866
867 if (abs(z) < cut) then
868 phi1 = m_one + m_half*z*(m_one + z/m_three*(m_one + m_fourth*z*(m_one + z/m_five)))
869 else
870 phi1 = (exp(z) - m_z1)/z
871 end if
872 end function phi1
873
874 ! -------------------------------------------------------
881 complex(real64) pure function phi2(z)
882 complex(real64), intent(in) :: z
883
884 real(real64), parameter :: cut = 0.002_real64
885
886 if (abs(z) < cut) then
887 phi2 = m_half + z/6.0_real64*(m_one + m_fourth*z*(m_one + z/m_five*(m_one + z/6.0_real64)))
888 else
889 phi2 = (exp(z) - z - m_z1)/z**2
890 end if
891 end function phi2
892
893 ! -------------------------------------------------------
895 real(real64) pure function square_root(x)
896 real(real64), intent(in) :: x
897
898 square_root = sqrt(x)
899 end function square_root
900
901 ! -------------------------------------------------------
902
903 logical function is_prime(n)
904 integer, intent(in) :: n
905
906 integer :: i, root
907
908 push_sub(is_prime)
909
910 if (n < 1) then
911 message(1) = "Internal error: is_prime does not take negative numbers."
912 call messages_fatal(1)
913 end if
914 if (n == 1) then
915 is_prime = .false.
916 pop_sub(is_prime)
917 return
918 end if
920 root = nint(sqrt(real(n, real64) ))
921 do i = 2, root
922 if (mod(n,i) == 0) then
923 is_prime = .false.
924 pop_sub(is_prime)
925 return
926 end if
927 end do
928
929 is_prime = .true.
930 pop_sub(is_prime)
931 end function is_prime
932
933 ! ---------------------------------------------------------
938 subroutine generate_rotation_matrix(R, ff, tt)
939 real(real64), intent(out) :: r(:,:)
940 real(real64), intent(in) :: ff(:)
941 real(real64), intent(in) :: tt(:)
942
943 integer :: dim, i, j
944 real(real64) :: th, uv, uu, vv, ft
945 real(real64), allocatable :: axis(:), u(:), v(:), f(:), t(:), p(:)
946
948
949 dim = size(ff,1)
950
951 assert((dim < 3) .or. (dim > 2))
952 assert(size(tt,1) == dim)
953 assert((size(r,1) == dim) .and. (size(r,2) == dim))
954
955 safe_allocate(u(1:dim))
956 safe_allocate(v(1:dim))
957 safe_allocate(f(1:dim))
958 safe_allocate(t(1:dim))
959
960
961 !normalize
962 f = ff / norm2(ff)
963 t = tt / norm2(tt)
964
965 ft = dot_product(f,t)
966
967 if (abs(ft) < m_one) then
968 select case (dim)
969 case (2)
970 th = acos(ft)
971 r(1,1) = cos(th)
972 r(1,2) = -sin(th)
973
974 r(2,1) = sin(th)
975 r(2,2) = cos(th)
976
977 case (3)
978 if (.false.) then
979 !Old implementation
980 safe_allocate(axis(1:dim))
981 th = acos(ft)
982
983 u = f / dot_product(f,f)
984 v = t /dot_product(t,t)
985
986 axis = dcross_product(u,v)
987 axis = axis / norm2(axis)
989 r(1,1) = cos(th) + axis(1)**2 * (1 - cos(th))
990 r(1,2) = axis(1)*axis(2)*(1-cos(th)) + axis(3)*sin(th)
991 r(1,3) = axis(1)*axis(3)*(1-cos(th)) - axis(2)*sin(th)
992
993 r(2,1) = axis(2)*axis(1)*(1-cos(th)) - axis(3)*sin(th)
994 r(2,2) = cos(th) + axis(2)**2 * (1 - cos(th))
995 r(2,3) = axis(2)*axis(3)*(1-cos(th)) + axis(1)*sin(th)
997 r(3,1) = axis(3)*axis(1)*(1-cos(th)) + axis(2)*sin(th)
998 r(3,2) = axis(3)*axis(2)*(1-cos(th)) - axis(1)*sin(th)
999 r(3,3) = cos(th) + axis(3)**2 * (1 - cos(th))
1000
1001 safe_deallocate_a(axis)
1002 end if
1003
1004 if (.true.) then
1005 !Naive implementation
1006 th = acos(ft)
1007 u = dcross_product(f,t)
1008 u = u / norm2(u)
1009
1010 r(1,1) = u(1)**2 + (1-u(1)**2)*cos(th)
1011 r(1,2) = u(1)*u(2)*(1-cos(th)) - u(3)*sin(th)
1012 r(1,3) = u(1)*u(3) + u(2)*sin(th)
1013
1014 r(2,1) = u(1)*u(2)*(1-cos(th)) + u(3)*sin(th)
1015 r(2,2) = u(2)**2 + (1-u(2)**2)*cos(th)
1016 r(2,3) = u(2)*u(3)*(1-cos(th)) - u(1)*sin(th)
1017
1018 r(3,1) = u(1)*u(3)*(1-cos(th)) - u(2)*sin(th)
1019 r(3,2) = u(2)*u(3)*(1-cos(th)) + u(1)*sin(th)
1020 r(3,3) = u(3)**2 + (1-u(3)**2)*cos(th)
1021 end if
1022
1023 if (.false.) then
1024 !Fast
1025 safe_allocate(p(1:dim))
1026
1027 if (abs(f(1)) <= abs(f(2)) .and. abs(f(1)) < abs(f(3))) then
1028 p = (/m_one, m_zero, m_zero/)
1029 else if (abs(f(2)) < abs(f(1)) .and. abs(f(2)) <= abs(f(3))) then
1030 p = (/m_zero, m_one, m_zero/)
1031 else if (abs(f(3)) <= abs(f(1)) .and. abs(f(3)) < abs(f(2))) then
1032 p = (/m_zero, m_zero, m_one/)
1033 end if
1034
1035 u = p - f
1036 v = p - t
1037
1038 uu = dot_product(u,u)
1039 vv = dot_product(v,v)
1040 uv = dot_product(u,v)
1041
1042 do i = 1,3
1043 do j = 1,3
1044
1045 r(i,j) = ddelta(i,j) - m_two * u(i)*u(j)/uu - m_two * v(i)*v(j)/vv &
1046 + 4_real64*uv * v(i)*u(j) /(uu*vv)
1047
1048 end do
1049 end do
1050
1051 safe_deallocate_a(p)
1052 end if
1053
1054
1055 end select
1056
1057 else
1058
1059 r = m_zero
1060 do i = 1,dim
1061 r(i,i) = m_one
1062 end do
1063
1064 end if
1065
1066
1067 safe_deallocate_a(u)
1068 safe_deallocate_a(v)
1069
1071 end subroutine generate_rotation_matrix
1072
1073 ! ---------------------------------------------------------
1082 subroutine numder_ridders(x, h, res, err, f)
1083 implicit none
1084 real(real64), intent(in) :: x, h
1085 real(real64), intent(out) :: res, err
1086 interface
1087 subroutine f(x, fx)
1088 use, intrinsic :: iso_fortran_env
1089 implicit none
1090 real(real64), intent(in) :: x
1091 real(real64), intent(inout) :: fx
1092 end subroutine f
1093 end interface
1094
1095 real(real64), parameter :: con = 1.4_real64, big = 1.0e30_real64, safe = m_two
1096 integer, parameter :: ntab = 20
1097 integer :: i, j
1098 real(real64) :: errt, fac, hh, fx1, fx2
1099 real(real64), allocatable :: a(:, :)
1100
1101 push_sub(numder_ridders)
1102
1103 if (abs(h) <= m_epsilon) then
1104 message(1) = "h must be nonzero in numder_ridders"
1105 call messages_fatal(1)
1106 end if
1107
1108 safe_allocate(a(1:ntab, 1:ntab))
1109
1110 hh = h
1111 call f(x+hh, fx1)
1112 call f(x-hh, fx2)
1113 a(1,1) = (fx1-fx2) / (m_two*hh)
1114 err = big
1115 do i = 2, ntab
1116 hh = hh / con
1117 call f(x+hh, fx1)
1118 call f(x-hh, fx2)
1119 a(1,i) = (fx1-fx2) / (m_two*hh)
1120 fac = con**2
1121 do j = 2, i
1122 a(j,i) = (a(j-1,i)*fac-a(j-1,i-1)) / (fac-m_one)
1123 fac = con**2*fac
1124 errt = max(abs(a(j,i)-a(j-1,i)),abs(a(j,i)-a(j-1,i-1)))
1125 if (errt .le. err) then
1126 err = errt
1127 res = a(j,i)
1128 end if
1129 end do
1130 if (abs(a(i,i)-a(i-1,i-1)) .ge. safe*err) return
1131 end do
1132
1133 safe_deallocate_a(a)
1134 pop_sub(numder_ridders)
1135 end subroutine numder_ridders
1136
1137 ! ---------------------------------------------------------
1138 pure function dzcross_product(a, b) result(c)
1139 real(real64), intent(in) :: a(:)
1140 complex(real64), intent(in) :: b(:)
1141
1142 complex(real64) :: c(1:3)
1143
1144 c(1) = a(2)*b(3) - a(3)*b(2)
1145 c(2) = a(3)*b(1) - a(1)*b(3)
1146 c(3) = a(1)*b(2) - a(2)*b(1)
1147
1148 end function dzcross_product
1149
1150 ! ---------------------------------------------------------
1151 pure function zdcross_product(a, b) result(c)
1152 complex(real64), intent(in) :: a(:)
1153 real(real64), intent(in) :: b(:)
1154
1155 complex(real64) :: c(1:3)
1156
1157 c(1) = a(2)*b(3) - a(3)*b(2)
1158 c(2) = a(3)*b(1) - a(1)*b(3)
1159 c(3) = a(1)*b(2) - a(2)*b(1)
1160
1161 end function zdcross_product
1162
1163
1164!*****************************************************************************80
1165!
1166!! LM_POLYNOMIAL evaluates Laguerre polynomials Lm(n,m,x).
1167!
1168! First terms:
1169!
1170! M = 0
1171!
1172! Lm(0,0,X) = 1
1173! Lm(1,0,X) = -X + 1
1174! Lm(2,0,X) = X^2 - 4 X + 2
1175! Lm(3,0,X) = -X^3 + 9 X^2 - 18 X + 6
1176! Lm(4,0,X) = X^4 - 16 X^3 + 72 X^2 - 96 X + 24
1177! Lm(5,0,X) = -X^5 + 25 X^4 - 200 X^3 + 600 X^2 - 600 x + 120
1178! Lm(6,0,X) = X^6 - 36 X^5 + 450 X^4 - 2400 X^3 + 5400 X^2 - 4320 X + 720
1179!
1180! M = 1
1181!
1182! Lm(0,1,X) = 0
1183! Lm(1,1,X) = -1,
1184! Lm(2,1,X) = 2 X - 4,
1185! Lm(3,1,X) = -3 X^2 + 18 X - 18,
1186! Lm(4,1,X) = 4 X^3 - 48 X^2 + 144 X - 96
1187!
1188! M = 2
1189!
1190! Lm(0,2,X) = 0
1191! Lm(1,2,X) = 0,
1192! Lm(2,2,X) = 2,
1193! Lm(3,2,X) = -6 X + 18,
1194! Lm(4,2,X) = 12 X^2 - 96 X + 144
1195!
1196! M = 3
1197!
1198! Lm(0,3,X) = 0
1199! Lm(1,3,X) = 0,
1200! Lm(2,3,X) = 0,
1201! Lm(3,3,X) = -6,
1202! Lm(4,3,X) = 24 X - 96
1203!
1204! M = 4
1205!
1206! Lm(0,4,X) = 0
1207! Lm(1,4,X) = 0
1208! Lm(2,4,X) = 0
1209! Lm(3,4,X) = 0
1210! Lm(4,4,X) = 24
1211!
1212! Recursion:
1213!
1214! Lm(0,M,X) = 1
1215! Lm(1,M,X) = (M+1-X)
1216!
1217! if 2 <= N:
1218!
1219! Lm(N,M,X) = ( (M+2*N-1-X) * Lm(N-1,M,X)
1220! + (1-M-N) * Lm(N-2,M,X) ) / N
1221!
1222! Special values:
1223!
1224! For M = 0, the associated Laguerre polynomials Lm(N,M,X) are equal
1225! to the Laguerre polynomials L(N,X).
1226!
1227! Licensing:
1228!
1229! This code is distributed under the GNU LGPL license.
1230!
1231! Modified:
1232!
1233! 08 February 2003
1234!
1235! Author:
1236!
1237! John Burkardt
1238!
1239! Reference:
1240!
1241! Milton Abramowitz, Irene Stegun,
1242! Handbook of Mathematical Functions,
1243! National Bureau of Standards, 1964,
1244! ISBN: 0-486-61272-4,
1245! LC: QA47.A34.
1246!
1247! Parameters:
1248!
1249! Input, integer ( kind = 4 ) MM, the number of evaluation points.
1250!
1251! Input, integer ( kind = 4 ) N, the highest order polynomial to compute.
1252! Note that polynomials 0 through N will be computed.
1253!
1254! Input, integer ( kind = 4 ) M, the parameter. M must be nonnegative.
1255!
1256! Input, real ( kind = rk ) X(MM), the evaluation points.
1257!
1258! Output, real ( kind = rk ) CX(MM,0:N), the associated Laguerre polynomials
1259! of degrees 0 through N evaluated at the evaluation points.
1260!
1261! Taken from
1262! https://people.sc.fsu.edu/~jburkardt/f_src/laguerre_polynomial/laguerre_polynomial.html
1263! and adapted to Octopus by N. Tancogne-Dejean
1264 subroutine generalized_laguerre_polynomial ( np, nn, mm, xx, cx )
1265 integer, intent(in) :: np
1266 integer, intent(in) :: nn, mm
1267 real(real64), intent(in) :: xx(np)
1268 real(real64), intent(out) :: cx(np)
1269
1270 integer ii
1271 real(real64), allocatable :: cx_tmp(:,:)
1272
1273 assert(mm >= 0)
1274
1275 safe_allocate(cx_tmp(1:np, 0:nn))
1276
1277 if (nn < 0) then
1278 cx = m_zero
1279 return
1280 end if
1281
1282 if (nn == 0) then
1283 cx(1:np) = m_one
1284 return
1285 end if
1286
1287 cx_tmp(1:np,0) = m_one
1288 cx_tmp(1:np,1) = real(mm + 1, real64) - xx(1:np)
1289
1290 do ii = 2, nn
1291 cx_tmp(1:np, ii) = &
1292 (( real(mm + 2*ii - 1, real64) - xx(1:np)) * cx_tmp(1:np,ii-1) &
1293 + real(-mm -ii + 1, real64) * cx_tmp(1:np,ii-2)) / real(ii, real64)
1294 end do
1295
1296 cx(1:np) = cx_tmp(1:np, nn)
1297
1298 safe_deallocate_a(cx_tmp)
1299
1300 end subroutine generalized_laguerre_polynomial
1301
1302 subroutine dupper_triangular_to_hermitian(nn, aa)
1303 integer, intent(in) :: nn
1304 real(real64), intent(inout) :: aa(:, :)
1305
1306 integer :: ii, jj
1307
1308 do jj = 1, nn
1309 do ii = 1, jj-1
1310 aa(jj, ii) = aa(ii, jj)
1311 end do
1312 end do
1313 end subroutine dupper_triangular_to_hermitian
1314
1315 subroutine zupper_triangular_to_hermitian(nn, aa)
1316 integer, intent(in) :: nn
1317 complex(real64), intent(inout) :: aa(:, :)
1318
1319 integer :: ii, jj
1320
1321 do jj = 1, nn
1322 do ii = 1, jj-1
1323 aa(jj, ii) = conjg(aa(ii, jj))
1324 end do
1325 aa(jj, jj) = real(aa(jj, jj), real64)
1326 end do
1327 end subroutine zupper_triangular_to_hermitian
1328
1329 subroutine dlower_triangular_to_hermitian(nn, aa)
1330 integer, intent(in) :: nn
1331 real(real64), intent(inout) :: aa(:, :)
1332
1333 integer :: ii, jj
1334
1335 do jj = 1, nn
1336 do ii = 1, jj-1
1337 aa(ii, jj) = aa(jj, ii)
1338 end do
1339 end do
1340 end subroutine dlower_triangular_to_hermitian
1341
1342 subroutine zlower_triangular_to_hermitian(nn, aa)
1343 integer, intent(in) :: nn
1344 complex(real64), intent(inout) :: aa(:, :)
1345
1346 integer :: ii, jj
1347
1348 do jj = 1, nn
1349 do ii = 1, jj-1
1350 aa(ii, jj) = conjg(aa(jj, ii))
1351 end do
1352 aa(jj, jj) = real(aa(jj, jj), real64)
1353 end do
1354 end subroutine zlower_triangular_to_hermitian
1355
1356
1357 subroutine dsymmetrize_matrix(nn, aa)
1358 integer, intent(in) :: nn
1359 real(real64), intent(inout) :: aa(:, :)
1360
1361 integer :: ii, jj
1362
1363 do ii = 1, nn
1364 do jj = ii+1, nn
1365 aa(ii, jj) = m_half * (aa(ii, jj) + aa(jj, ii))
1366 aa(jj, ii) = aa(ii, jj)
1367 end do
1368 end do
1369 end subroutine dsymmetrize_matrix
1370
1371 subroutine dzero_small_elements_matrix(nn, aa, tol)
1372 integer, intent(in) :: nn
1373 real(real64), intent(inout) :: aa(:, :)
1374 real(real64) :: tol
1375
1376 where(abs(aa)<tol)
1377 aa = m_zero
1378 end where
1379 end subroutine dzero_small_elements_matrix
1380
1382 logical function is_symmetric(a, tol)
1383 real(real64), intent(in) :: a(:, :)
1384 real(real64), optional, intent(in) :: tol
1385
1386 real(real64) :: tolerance
1387
1388 push_sub(is_symmetric)
1389
1390 tolerance = optional_default(tol, 1.0e-8_real64)
1391 ! a must be square
1392 assert(size(a, 1) == size(a, 2))
1393
1394 is_symmetric = all(abs(a - transpose(a)) < tolerance)
1396 pop_sub(is_symmetric)
1397
1398 end function is_symmetric
1399
1401 logical pure function is_diagonal(dim, matrix, tol)
1402 integer, intent(in) :: dim
1403 real(real64), intent(in) :: matrix(:, :)
1404 real(real64), intent(in) :: tol
1405
1406 integer :: ii, jj
1407 real(real64) :: max_diag
1409 max_diag = m_zero
1410 do ii = 1, dim
1411 max_diag = max(abs(matrix(ii, ii)), max_diag)
1412 end do
1413
1414 is_diagonal = .true.
1415 do ii = 1, dim
1416 do jj = 1, dim
1417 if (ii == jj) cycle
1418 if (abs(matrix(ii, jj)) > tol*max_diag) is_diagonal = .false.
1419 end do
1420 end do
1421
1422 end function is_diagonal
1423
1425 subroutine convert_to_base(num, base, converted)
1426 integer, intent(in) :: num
1427 integer, intent(in) :: base
1428 integer, intent(out) :: converted(:)
1429
1430 integer :: i, num_, length
1431
1432 ! no PUSH_SUB, called too often
1433
1434 converted = 0
1435 if (num > 0) then
1436 ! length of converted number
1437 length = floor(log(real(num, real64)) / log(real(base, real64))) + 1
1438 assert(size(converted) >= length)
1439
1440 num_ = num
1441 ! do conversion by repeated division
1442 do i = 1, size(converted)
1443 converted(i) = mod(num_, base)
1444 num_ = num_ / base
1445 end do
1446 end if
1447
1448 end subroutine convert_to_base
1449
1451 subroutine convert_from_base(converted, base, num)
1452 integer, intent(in) :: converted(:)
1453 integer, intent(in) :: base
1454 integer, intent(out) :: num
1455
1456 integer :: i
1457
1458 ! no PUSH_SUB, called too often
1459
1460 num = m_zero
1461 do i = 1, size(converted)
1462 num = num + converted(i) * base**(i-1)
1463 end do
1465 end subroutine convert_from_base
1466
1467
1468#include "undef.F90"
1469#include "complex.F90"
1470#include "math_inc.F90"
1471
1472#include "undef.F90"
1473#include "real.F90"
1474#include "math_inc.F90"
1476end module math_oct_m
1477
1478!! Local Variables:
1479!! mode: f90
1480!! coding: utf-8
1481!! End:
This is the common interface to a simple-minded polynomical interpolation procedure (simple use of th...
Definition: math.F90:188
double acos(double __x) __attribute__((__nothrow__
double log(double __x) __attribute__((__nothrow__
double exp(double __x) __attribute__((__nothrow__
double sin(double __x) __attribute__((__nothrow__
double sqrt(double __x) __attribute__((__nothrow__
double cos(double __x) __attribute__((__nothrow__
double atan2(double __y, double __x) __attribute__((__nothrow__
double floor(double __x) __attribute__((__nothrow__
real(real64), parameter, public m_two
Definition: global.F90:190
real(real64), parameter, public m_zero
Definition: global.F90:188
real(real64), parameter, public m_four
Definition: global.F90:192
real(real64), parameter, public m_pi
some mathematical constants
Definition: global.F90:186
complex(real64), parameter, public m_z0
Definition: global.F90:198
real(real64), parameter, public m_half
Definition: global.F90:194
real(real64), parameter, public m_one
Definition: global.F90:189
real(real64), parameter, public m_three
Definition: global.F90:191
This module is intended to contain "only mathematical" functions and procedures.
Definition: math.F90:115
complex(real64) pure function, public phi2(z)
Compute phi2(z) = (phi1(z)-1)/z = (exp(z) - z - 1)/z^2.
Definition: math.F90:975
integer pure function ilog2(xx)
Definition: math.F90:928
logical pure function, public even(n)
Returns if n is even.
Definition: math.F90:694
pure real(real64) function, dimension(dim, dim) ddiagonal_matrix(dim, diag)
Currently only returns a matrix whose diagonal elements are all the same. Note that the integer versi...
Definition: math.F90:1823
subroutine, public generalized_laguerre_polynomial(np, nn, mm, xx, cx)
Definition: math.F90:1358
complex(real64) pure function, public exponential(z)
Wrapper for exponential.
Definition: math.F90:944
subroutine dinterpolate_0(xa, ya, x, y)
Definition: math.F90:1901
subroutine, public ylmr_cmplx(xx, li, mi, ylm)
Computes spherical harmonics ylm at position (x, y, z)
Definition: math.F90:306
subroutine zinterpolate_0(xa, ya, x, y)
Definition: math.F90:1710
subroutine, public convert_to_base(num, base, converted)
convert an integer in base 10 to a different base
Definition: math.F90:1519
subroutine dinterpolate_1(xa, ya, x, y)
Definition: math.F90:1873
real(real64) pure function dlog2(xx)
Definition: math.F90:920
integer(int64) pure function pad88(size, blk)
Definition: math.F90:847
real(real64) pure function, public square_root(x)
Wrapper for sqrt.
Definition: math.F90:989
logical function, public member(n, a)
Considers a(1:ubound(a, 1)) as an integer set and checks if n is a member of it.
Definition: math.F90:650
integer pure function pad4(size, blk)
Definition: math.F90:878
subroutine dlower_triangular_to_hermitian(nn, aa)
Definition: math.F90:1423
pure complex(real64) function, dimension(1:3), public dzcross_product(a, b)
Definition: math.F90:1232
subroutine, public cartesian2hyperspherical(x, u)
Performs a transformation of an n-dimensional vector from Cartesian coordinates to hyperspherical coo...
Definition: math.F90:714
integer pure function, public pad_pow2(size)
create array size, which is padded to powers of 2
Definition: math.F90:891
subroutine zinterpolate_1(xa, ya, x, y)
Definition: math.F90:1682
pure real(real64) function, dimension(1:3), public dcross_product(a, b)
Definition: math.F90:1926
integer(int64) pure function pad48(size, blk)
Definition: math.F90:862
subroutine dsymmetrize_matrix(nn, aa)
Definition: math.F90:1451
subroutine, public ylmr_real(xx, li, mi, ylm)
This is a Numerical Recipes-based subroutine computes real spherical harmonics ylm at position (x,...
Definition: math.F90:377
subroutine dupper_triangular_to_hermitian(nn, aa)
Definition: math.F90:1396
subroutine, public interpolation_coefficients(nn, xa, xx, cc)
Definition: math.F90:671
logical function, public is_symmetric(a, tol)
Check if a 2D array is symmetric.
Definition: math.F90:1476
subroutine, public generate_rotation_matrix(R, ff, tt)
Generates a rotation matrix R to rotate a vector f to t.
Definition: math.F90:1032
elemental logical function zis_close_scalar(x, y, rtol, atol)
Same as dis_close_scalar for complex numbers.
Definition: math.F90:239
logical pure function, public odd(n)
Returns if n is odd.
Definition: math.F90:704
real(real64) pure function, public ddelta(i, j)
Definition: math.F90:603
subroutine, public make_idx_set(n, out, length, in)
Construct out(1:length) = (/1, ..., n/) if in is not present, out(1:length) = in otherwise.
Definition: math.F90:621
logical function, public is_prime(n)
Definition: math.F90:997
complex(real64) pure function, public phi1(z)
Compute phi1(z) = (exp(z)-1)/z.
Definition: math.F90:956
pure complex(real64) function, dimension(1:3), public zcross_product(a, b)
Definition: math.F90:1735
subroutine, public weights(N, M, cc, side)
Compute the weights for finite-difference calculations:
Definition: math.F90:527
subroutine zinterpolate_2(xa, ya, x, y)
Definition: math.F90:1647
pure complex(real64) function, dimension(dim, dim) zdiagonal_matrix(dim, diag)
Currently only returns a matrix whose diagonal elements are all the same. Note that the integer versi...
Definition: math.F90:1632
subroutine zlower_triangular_to_hermitian(nn, aa)
Definition: math.F90:1436
logical pure function, public is_diagonal(dim, matrix, tol)
Returns true is the matrix of size dim x dim is diagonal, given a relative tolerance.
Definition: math.F90:1495
subroutine zupper_triangular_to_hermitian(nn, aa)
Definition: math.F90:1409
pure integer function, dimension(dim, dim) idiagonal_matrix(dim, diag)
Currently only returns a matrix whose diagonal elements are all the same. Note that the real and comp...
Definition: math.F90:255
integer(int64) pure function pad8(size, blk)
Definition: math.F90:870
subroutine dinterpolate_2(xa, ya, x, y)
Definition: math.F90:1838
subroutine, public numder_ridders(x, h, res, err, f)
Numerical derivative (Ridder`s algorithm).
Definition: math.F90:1176
integer(int64) pure function llog2(xx)
Definition: math.F90:936
recursive real(real64) function, public hermite(n, x)
Definition: math.F90:270
elemental logical function dis_close_scalar(x, y, rtol, atol)
Are and equal within a tolerance.
Definition: math.F90:226
pure complex(real64) function, dimension(1:3), public zdcross_product(a, b)
Definition: math.F90:1245
subroutine, public convert_from_base(converted, base, num)
convert an integer to base 10 from a different base
Definition: math.F90:1545
subroutine, public hyperspherical2cartesian(u, x)
Performs the inverse transformation of cartesian2hyperspherical.
Definition: math.F90:761
subroutine, public dzero_small_elements_matrix(nn, aa, tol)
Definition: math.F90:1465
subroutine, public hypersphere_grad_matrix(grad_matrix, r, x)
Gives the hyperspherical gradient matrix, which contains the derivatives of the Cartesian coordinates...
Definition: math.F90:807
recursive integer function, public factorial(n)
Definition: math.F90:290
static double f(double w, void *p)
int true(void)