Skip to content

Commit

Permalink
update to cohprods docs and change nnzohp/ind to inout
Browse files Browse the repository at this point in the history
  • Loading branch information
nimgould committed Jan 22, 2024
1 parent 2d7f418 commit d957aaa
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 31 deletions.
Binary file modified doc/pdf/cutest_cohprods.pdf
Binary file not shown.
Binary file modified doc/pdf/cutest_cohprods_threaded.pdf
Binary file not shown.
10 changes: 7 additions & 3 deletions man/man3/cutest_cohprods.3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For real rather than double precision arguments, instead
.HP 1i
CALL CUTEST_cohprods_s( ... )
.SH DESCRIPTION
The CUTEST_cohprods subroutine forms the product of a vector with
The CUTEST_cohprods subroutine forms the product of a vector with
the Hessian matrix of the objective function
.EQ
f(x)
Expand Down Expand Up @@ -83,7 +83,7 @@ the number of variables for the problem,
a logical variable which specifies whether the second derivatives of
the groups and elements, and the indexing information held in IND
(see below) have already been set (goth = .TRUE.) or if
this information should be computed (goth = .FALSE.),
this information should be computed (goth = .FALSE.).
.TP
.B X \fP[in] - real/double precision
when goth = .FALSE., the Hessians will be evaluated at X. Otherwise
Expand All @@ -95,7 +95,9 @@ required,
.TP
.B nnzohp \fP[out] - integer
the total number of nonzero entries required to store the product of the
objective Hessian with a vector.
objective Hessian with a vector. This should be the value obtained
from the last call to the subroutine if goth = .TRUE., but need not be
set otherwise.
.TP
.B lohp \fP[in] - integer
a variable that specifies the declared lengths of IND and RESULT.
Expand All @@ -111,6 +113,8 @@ stored in RESULT(1:nnzohp).
an array that gives the indices of the nonzeros in the result obtained by
multiplying the objective Hessian by VECTOR. The indices
are stored in IND(1:nnzohp), and will match the values stored in RESULT.
This array should be passed unchanged from the last call to the subroutine
if goth = .TRUE., but need not be set otherwise.
.LP
.SH NOTE
goth should be set to .TRUE. only when
Expand Down
8 changes: 6 additions & 2 deletions man/man3/cutest_cohprods_threaded.3
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CUTEST_cohprods_threaded \- CUTEst tool to form the matrix-vector product
of a vector with the Hessian matrix of the objective function.
.SH SYNOPSIS
.HP 1i
CALL CUTEST_cohprods_threaded( status, goth, X, VECTOR,
CALL CUTEST_cohprods_threaded( status, goth, X, VECTOR,
nnzohp, lohp, RESULT, IND, thread )

.HP 1i
Expand Down Expand Up @@ -96,7 +96,9 @@ required,
.TP
.B nnzohp \fP[out] - integer
the total number of nonzero entries required to store the product of the
objective Hessian with a vector.
objective Hessian with a vector. This should be the value obtained
from the last call to the subroutine if goth = .TRUE., but need not be
set otherwise.
.TP
.B lohp \fP[in] - integer
a variable that specifies the declared lengths of IND and RESULT.
Expand All @@ -112,6 +114,8 @@ stored in RESULT(1:nnzohp).
an array that gives the indices of the nonzeros in the result obtained by
multiplying the objective Hessian by VECTOR. The indices
are stored in IND(1:nnzohp), and will match the values stored in RESULT.
This array should be passed unchanged from the last call to the subroutine
if goth = .TRUE., but need not be set otherwise.
.TP
.B thread \fP[out] - integer
thread chosen for the evaluation; threads are numbered
Expand Down
4 changes: 3 additions & 1 deletion man/man3/makedocs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@

#foreach pack ( cutest_cdhj cutest_cdhj_threaded )

foreach pack ( cutest_chjprod cutest_chjprod_threaded )
#foreach pack ( cutest_chjprod cutest_chjprod_threaded )

foreach pack ( cutest_cohprods cutest_cohprods_threaded )

#foreach pack ( cutest_cdimohp cutest_cdimsg \
# cutest_chjprod cutest_chjprod_threaded \
Expand Down
56 changes: 31 additions & 25 deletions src/tools/cohprods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@ SUBROUTINE CUTEST_Cint_cohprods_r( status, n, goth, X, VECTOR, &
! dummy arguments

INTEGER ( KIND = ip_ ), INTENT( IN ) :: n, lohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status, nnzohp
INTEGER ( KIND = ip_ ), INTENT( INOUT ) :: nnzohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status
LOGICAL ( KIND = C_Bool ), INTENT( IN ) :: goth
REAL ( KIND = rp_ ), INTENT( IN ), DIMENSION( n ) :: X, VECTOR
INTEGER ( KIND = ip_ ), INTENT( OUT ), DIMENSION( lohp ) :: IND
INTEGER ( KIND = ip_ ), INTENT( INOUT ), DIMENSION( lohp ) :: IND
REAL ( KIND = rp_ ), INTENT( OUT ), DIMENSION( lohp ) :: RESULT

! ---------------------------------------------------------------------------
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! VECTOR. The nonzero entries of the resulting products H(x) v and their
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed.
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed, and
! that nnzohp and IND have been set by a previous call at X.
! If the user is unsure, set goth = .FALSE. the first time a product is
! required with the Hessians evaluated at X. X is not used if goth = .TRUE.
! ---------------------------------------------------------------------------
Expand Down Expand Up @@ -63,18 +65,20 @@ SUBROUTINE CUTEST_cohprods_r( status, n, goth, X, VECTOR, &
! dummy arguments

INTEGER ( KIND = ip_ ), INTENT( IN ) :: n, lohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status, nnzohp
INTEGER ( KIND = ip_ ), INTENT( INOUT ) :: nnzohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status
LOGICAL, INTENT( IN ) :: goth
REAL ( KIND = rp_ ), INTENT( IN ), DIMENSION( n ) :: X, VECTOR
INTEGER ( KIND = ip_ ), INTENT( OUT ), DIMENSION( lohp ) :: IND
REAL ( KIND = rp_ ), INTENT( OUT ), DIMENSION( lohp ) :: RESULT

! ---------------------------------------------------------------------------
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! VECTOR. The nonzero entries of the resulting products H(x) v and their
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed.
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed, and
! that nnzohp and IND have been set by a previous call at X.
! If the user is unsure, set goth = .FALSE. the first time a product is
! required with the Hessians evaluated at X. X is not used if goth = .TRUE.
! ---------------------------------------------------------------------------
Expand All @@ -97,26 +101,28 @@ END SUBROUTINE CUTEST_cohprods_r
! History -
! moden fortran version released in CUTEst, 29th October 2023

SUBROUTINE CUTEST_cohprods_threaded_r( status, n, goth, X, VECTOR, &
SUBROUTINE CUTEST_cohprods_threaded_r( status, n, goth, X, VECTOR, &
nnzohp, lohp, RESULT, IND, thread )
USE CUTEST_KINDS_precision
USE CUTEST_precision

! dummy arguments

INTEGER ( KIND = ip_ ), INTENT( IN ) :: n, lohp, thread
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status, nnzohp
INTEGER ( KIND = ip_ ), INTENT( INOUT ) :: nnzohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status
LOGICAL, INTENT( IN ) :: goth
REAL ( KIND = rp_ ), INTENT( IN ), DIMENSION( n ) :: X, VECTOR
INTEGER ( KIND = ip_ ), INTENT( OUT ), DIMENSION( lohp ) :: IND
REAL ( KIND = rp_ ), INTENT( OUT ), DIMENSION( lohp ) :: RESULT

! ---------------------------------------------------------------------------
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! VECTOR. The nonzero entries of the resulting products H(x) v and their
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed.
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed, and
! that nnzohp and IND have been set by a previous call at X.
! If the user is unsure, set goth = .FALSE. the first time a product is
! required with the Hessians evaluated at X. X is not used if goth = .TRUE.
! ---------------------------------------------------------------------------
Expand Down Expand Up @@ -161,18 +167,20 @@ SUBROUTINE CUTEST_cohprods_threadsafe_r( data, work, status, n, goth, &
TYPE ( CUTEST_data_type ), INTENT( IN ) :: data
TYPE ( CUTEST_work_type ), INTENT( INOUT ) :: work
INTEGER ( KIND = ip_ ), INTENT( IN ) :: n, lohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status, nnzohp
INTEGER ( KIND = ip_ ), INTENT( INOUT ) :: nnzohp
INTEGER ( KIND = ip_ ), INTENT( OUT ) :: status
LOGICAL, INTENT( IN ) :: goth
REAL ( KIND = rp_ ), INTENT( IN ), DIMENSION( n ) :: X, VECTOR
INTEGER ( KIND = ip_ ), INTENT( OUT ), DIMENSION( lohp ) :: IND
REAL ( KIND = rp_ ), INTENT( OUT ), DIMENSION( lohp ) :: RESULT

! ---------------------------------------------------------------------------
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! compute the matrix-vector product H(x) between the Hessian matrices H(x)
! of the objective function for the problem and a given vector v stored in
! VECTOR. The nonzero entries of the resulting products H(x) v and their
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed.
! indices occur in RESULT(k),IND(k), k = 1,...,nnzohp. If goth is .TRUE.
! the second derivatives are assumed to have already been computed, and
! that nnzohp and IND have been set by a previous call at X.
! If the user is unsure, set goth = .FALSE. the first time a product is
! required with the Hessians evaluated at X. X is not used if goth = .TRUE.
! ---------------------------------------------------------------------------
Expand Down Expand Up @@ -462,7 +470,7 @@ SUBROUTINE CUTEST_cohprods_threadsafe_r( data, work, status, n, goth, &

! copy the nonzeros back to the sparse array, and reset W_ws to zero

RESULT( 1 : nnzohp ) = work%W_ws( IND( 1 : nnzohp ) )
RESULT( 1 : nnzohp ) = work%W_ws( IND( 1 : nnzohp ) )
work%W_ws( IND( 1 : nnzohp ) ) = 0.0_rp_

! update the counters for the report tool
Expand Down Expand Up @@ -494,5 +502,3 @@ SUBROUTINE CUTEST_cohprods_threadsafe_r( data, work, status, n, goth, &
! end of subroutine CUTEST_cohprods_threadsafe_r

END SUBROUTINE CUTEST_cohprods_threadsafe_r


0 comments on commit d957aaa

Please sign in to comment.