Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qq.f90
Go to the documentation of this file.
1 ! Copyright (c) 2011-2013 by Evangelos A. Coutsias and Michael J. Wester
2 ! Department of Mathematics and Statistics
3 ! University of New Mexico, Albuquerque, New Mexico, USA
4 ! Written by Evangelos A. Coutsias
5 
6 ! -----------------------------------------------------------------------------
7 !==============================================================================
8 MODULE dixon
9 !==============================================================================
10 USE globals
11 USE geom
12 !-----------------------------------------------------------------------------
13 CONTAINS
14 !subroutines
15 ! Dixon_Resultant_Real_Roots ! triaxial_coefficients ! RECONSTRUCT ! triangle ! charpoly
16 !functions
17 ! point_value2 ! point_value4 ! point_value6 ! point_value8 ! point_value16
18 ! point_product ! point_product4x2 ! point_product4x4 ! point_product8x6
19 ! poly_product ! poly_product2x2 ! poly_product4x2 ! poly_product4x4 ! poly_product4sq
20 ! poly_product6x6 ! poly_product12x4 ! poly_product8x8 ! poly_product8sq
21 !-----------------------------------------------------------------------------
22 SUBROUTINE dixon_resultant_real_roots( A, B, C, D, n_roots, u, method, flag)
23  implicit none
24 ! real (DP), external :: p
25 ! real (DP), intent(in) :: alpha(3), delta(0:2), eta(3), theta(3), xi(0:2)
26  integer, intent(in) :: method
27  integer, intent(inout) :: flag
28  integer, intent(out) :: n_roots
29  real (DP), intent(out) :: u(3, 16)
30 ! integer n_soln
31 ! real (DP) u2(3, 16)
32 !-----------------------------------------------------------------------------
33  integer i, j, n, info, k(16), ktmp
34  real (DP) a(0:2, 0:2), b(0:2, 0:2), c(0:2, 0:2), d(0:2, 0:2)
35  real (DP) r(0:2, 8, 8), ga(16, 16), gb(16, 16)
36  real (DP) e_alpha_r(16), e_alpha_i(16), e_beta(16), e(16), etmp, v(16, 16)
37  real (DP) denom
38  real start_time, stop_time
39 !-----------------------------------------------------------------------------
40 ! do i = 0, 2
41 ! do j = 0, 2
42 ! A(i,j) = p(i,1,2, alpha,delta,eta,theta,xi &
43 ! )*p(0,j,3, alpha,delta,eta,theta,xi &
44 ! ) - p(i,0,2, alpha,delta,eta,theta,xi &
45 ! )*p(1,j,3, alpha,delta,eta, &
46 ! theta,xi)
47 ! B(i,j) = p(i,2,2, alpha,delta,eta,theta,xi &
48 ! )*p(0,j,3, alpha,delta,eta,theta,xi &
49 ! ) - p(i,0,2, alpha,delta,eta,theta,xi &
50 ! )*p(2,j,3, alpha,delta,eta, &
51 ! theta,xi)
52 ! C(i,j) = p(i,2,2, alpha,delta,eta,theta,xi &
53 ! )*p(1,j,3, alpha,delta,eta,theta,xi &
54 ! ) - p(i,1,2, alpha,delta,eta,theta,xi &
55 ! )*p(2,j,3, alpha,delta,eta, &
56 ! theta,xi)
57 ! D(i,j) = p(j,i,1, alpha,delta,eta,theta,xi)
58 ! end do
59 ! end do
60 !-----------------------------------------------------------------------------
61 if (method == 1) then
62  do i = 0, 2
63  r(i, :, :) = reshape(source = &
64  (/ 0.0_dp, a(0,i), a(1,i), a(2,i), 0.0_dp, b(0,i), b(1,i), b(2,i), &
65  a(0,i), a(1,i), a(2,i), 0.0_dp, b(0,i), b(1,i), b(2,i), 0.0_dp, &
66  0.0_dp, b(0,i), b(1,i), b(2,i), 0.0_dp, c(0,i), c(1,i), c(2,i), &
67  b(0,i), b(1,i), b(2,i), 0.0_dp, c(0,i), c(1,i), c(2,i), 0.0_dp, &
68  0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, d(0,i), d(1,i), d(2,i), &
69  0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, d(0,i), d(1,i), d(2,i), 0.0_dp, &
70  0.0_dp, d(0,i), d(1,i), d(2,i), 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, &
71  d(0,i), d(1,i), d(2,i), 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp, 0.0_dp /),&
72  shape = (/ 8, 8 /), order = (/ 2, 1 /))
73  end do
74 
75  ! R_16 := expand(LinearAlgebra:-Determinant(R[0] + R[1]*u_3 + R[2]*u_3^2))
76  ! e := sort([fsolve(R_16, u_3)])
77 
78  ga = 0.0_dp
79  do i = 1, 8
80  ga(i, 8+i) = 1.0_dp
81  end do
82  ga(9:16, 1:8 ) = -r(0, :, :)
83  ga(9:16, 9:16) = -r(1, :, :)
84 
85  gb = 0.0_dp
86  do i = 1, 8
87  gb(i, i) = 1.0_dp
88  end do
89  gb(9:16, 9:16) = r(2, :, :)
90 
91  ! e is the vector of eigenvalues and v is the matrix of eigenvectors.
92  call cpu_time(start_time)
93 ! call la_ggev(gA, gB, e_alpha_r, e_alpha_i, e_beta, VR = v, INFO = info)
94  call rgg(16, 16, ga, gb, e_alpha_r, e_alpha_i, e_beta, 1, v, info)
95  call cpu_time(stop_time)
96 ! print '(/" Eigenvecs elapsed time: ",f7.3," seconds")', &
97 ! stop_time - start_time
98 
99  if (info /= 0) then
100  print '("Dixon_Resultant_Real_Roots: Eigenvector calculation failure,", &
101 & " info = ",i3)', &
102  info
103  end if
104 
105  ! Select only the real eigenvalues, enforce that they contain no imaginary
106  ! parts, and then sort them in order of increasing value.
107  ! n is the number of real eigenvalues discovered.
108  k = 0 ! Integer array; this line fills with zero.
109  n = 0 ! Integer index variable.
110 
111  ! k holds indices of real eigenvalues (and eigenvectors).
112  ! e holds the real eigenvalues themselves.
113 
114  do i = 1, 16
115  if (abs(e_alpha_i(i)) < epsilon(0.0_dp)) then
116  n = n + 1
117  k(n) = i
118  e(n) = e_alpha_r(i)/e_beta(i)
119  end if
120  end do
121 
122  ! Shitty n**2 sort of eigenvalues.
123  do i = 1, n - 1
124  do j = i + 1, n
125  if (e(i) > e(j)) then
126  etmp = e(i)
127  e(i) = e(j)
128  e(j) = etmp
129 
130  ktmp = k(i)
131  k(i) = k(j)
132  k(j) = ktmp
133  end if
134  end do
135  end do
136 
137  ! Sort the eigenvectors into the same order as the eigenvalues and also
138  ! enforce that they contain no imaginary parts.
139  ! e is v(9, :) / v(1, :).
140  n_roots = n
141  do i = 1, n
142  if (abs(v(1,k(i))) .gt. .00000001) then
143  denom = 1/v(1,k(i))
144  u(1, i) = v(2, k(i)) * denom
145  u(2, i) = v(5, k(i)) * denom
146  else ! still need to guard!!!
147  denom = 1/v(3,k(i))
148  u(1, i) = v(4, k(i)) * denom
149  u(2, i) = v(7, k(i)) * denom
150  endif
151 
152  ! u3 is just the eigenvalues; I already knew that.
153  u(3, i) = e(i)
154  end do
155 ! print*, 'using eig'
156 ! do i = 1, n_roots
157 ! print*, i, u(1,i), u(2,i), u(3,i)
158 ! enddo
159 else
160  call charpoly(a, b, c, d, n_roots, u, flag)
161 ! print*, 'using charpoly'
162 ! do i = 1, n_roots
163 ! print*, i, u2(1,i), u2(2,i), u2(3,i)
164 ! enddo
165  endif
166 
167 end SUBROUTINE dixon_resultant_real_roots
168 !==============================================================================
virtual VectorOption & n(Size const n_a)=0
Fixed number of values required assignment.
std::string print(utility::sql_database::sessionOP db_session) const
Definition: Column.cc:75
static void info(const char *fmt,...)
Definition: Svm.cc:48
size_type u() const
Upper index.
Definition: CArrayP.hh:620
ChunkVector & reshape(size_type const size_a, ChunkExponent const &chunk_exponent_a, T const &value=T())
Reshape + Fill Value: Values Preserved.
Definition: ChunkVector.hh:979