5 type, abstract
:: vector_class
8 !---------------------------------------------------------------
13 type, abstract
:: inner_product_class
15 procedure(dot
), deferred
:: dot_v_v
16 procedure(dot
), deferred
:: dot_g_g
17 procedure(sub
), deferred
:: D_times_v
18 procedure(sub
), deferred
:: D_times_g
19 end type inner_product_class
22 function dot (this
,a
,b
)
23 import
:: inner_product_class
24 import
:: vector_class
25 class(inner_product_class
), intent(in
) :: this
26 class(vector_class
), intent(in
) :: a
,b
29 subroutine sub (this
,a
)
30 import
:: inner_product_class
31 import
:: vector_class
32 class(inner_product_class
), intent(in
) :: this
33 class(vector_class
), intent(inout
) :: a
37 !---------------------------------------------------------------
43 public
:: gradient_class
45 type, abstract
, extends(vector_class
) :: gradient_class
46 class(inner_product_class
), pointer :: my_inner_product
=> NULL()
48 procedure
, non_overridable
:: inquire_inner_product
49 procedure(op_g_v
), deferred
:: to_vector
50 end type gradient_class
53 subroutine op_g_v(this
,v
)
56 class(gradient_class
), intent(in
) :: this
57 class(vector_class
), intent(inout
) :: v
61 function inquire_inner_product (this
)
62 class(gradient_class
) :: this
63 class(inner_product_class
), pointer :: inquire_inner_product
65 inquire_inner_product
=> this
%my_inner_product
66 end function inquire_inner_product
68 !---------------------------------------------------------------
74 subroutine cg (g_initial
)
75 class(gradient_class
), intent(in
) :: g_initial
77 class(inner_product_class
), pointer :: ip_save
78 ip_save
=> g_initial
%inquire_inner_product()