gtool5 Fortran 90/95 Library 1.0.0-rc5
日本語
Loading...
Searching...
No Matches
dc_scaledsec::modulo Interface Reference

Public Member Functions

type(dc_scaled_sec) function dcscaledsec_modulo_si (sclsec, factor)
type(dc_scaled_sec) function dcscaledsec_modulo_sr (sclsec, factor)
type(dc_scaled_sec) function dcscaledsec_modulo_sd (sclsec, factor)
type(dc_scaled_sec) function dcscaledsec_modulo_ss (sclsec, factor)

Detailed Description

Definition at line 228 of file dc_scaledsec.f90.

Member Function/Subroutine Documentation

◆ dcscaledsec_modulo_sd()

type(dc_scaled_sec) function dc_scaledsec::modulo::dcscaledsec_modulo_sd ( type(dc_scaled_sec), intent(in) sclsec,
real(dp), intent(in) factor )

Calculate modulo of DC_SCALED_SEC divided by double

Parameters
[in]sclsecDC_SCALED_SEC variable (dividend)
[in]factorDouble precision divisor
Returns
Modulo of division

Definition at line 2402 of file dc_scaledsec.f90.

2403 use dc_message, only: messagenotify
2404 implicit none
2405 type(DC_SCALED_SEC), intent(in):: sclsec
2406 real(DP), intent(in):: factor
2407 type(DC_SCALED_SEC):: factor_scl
2408
2409 continue
2410 factor_scl = factor
2411 result = modulo( sclsec, factor_scl )
Message output module.

◆ dcscaledsec_modulo_si()

type(dc_scaled_sec) function dc_scaledsec::modulo::dcscaledsec_modulo_si ( type(dc_scaled_sec), intent(in) sclsec,
integer, intent(in) factor )

Calculate modulo of DC_SCALED_SEC divided by integer

Parameters
[in]sclsecDC_SCALED_SEC variable (dividend)
[in]factorInteger divisor
Returns
Modulo of division

Definition at line 2348 of file dc_scaledsec.f90.

2349 use dc_message, only: messagenotify
2350 implicit none
2351 type(DC_SCALED_SEC), intent(in):: sclsec
2352 integer, intent(in):: factor
2353 type(DC_SCALED_SEC):: factor_scl
2354
2355 continue
2356 factor_scl = factor
2357 result = modulo( sclsec, factor_scl )

◆ dcscaledsec_modulo_sr()

type(dc_scaled_sec) function dc_scaledsec::modulo::dcscaledsec_modulo_sr ( type(dc_scaled_sec), intent(in) sclsec,
real, intent(in) factor )

Calculate modulo of DC_SCALED_SEC divided by real

Parameters
[in]sclsecDC_SCALED_SEC variable (dividend)
[in]factorSingle precision divisor
Returns
Modulo of division

Definition at line 2375 of file dc_scaledsec.f90.

2376 use dc_message, only: messagenotify
2377 implicit none
2378 type(DC_SCALED_SEC), intent(in):: sclsec
2379 real, intent(in):: factor
2380 type(DC_SCALED_SEC):: factor_scl
2381
2382 continue
2383 factor_scl = factor
2384 result = modulo( sclsec, factor_scl )

◆ dcscaledsec_modulo_ss()

type(dc_scaled_sec) function dc_scaledsec::modulo::dcscaledsec_modulo_ss ( type(dc_scaled_sec), intent(in) sclsec,
type(dc_scaled_sec), intent(in) factor )

Calculate modulo of DC_SCALED_SEC division

Note: Due to precision limitations in Fortran compilers, factor must be smaller than 10^12.

The difference from mod: modulo always returns a non-negative result when the divisor is positive (follows Fortran's modulo semantics).

Parameters
[in]sclsecDC_SCALED_SEC variable (dividend)
[in]factorDC_SCALED_SEC variable (divisor)
Returns
Modulo of division

Definition at line 2229 of file dc_scaledsec.f90.

2230 use dc_message, only: messagenotify
2231 use dc_types, only: dp_eps
2232 implicit none
2233 type(DC_SCALED_SEC), intent(in):: sclsec, factor
2234
2235 type(DC_SCALED_SEC):: factor_scl
2236 real(DP):: sec_ary_mod(imin+imin:imax)
2237 integer:: i, move_down_index, sf_idx
2238 real(DP):: move_down
2239 real(DP):: factor_dp
2240 type(DC_SCALED_SEC):: zero_sec
2241 logical:: done
2242 continue
2243
2244 ! factor must be smaller than 10^12 due to compiler precision limitations.
2245 !
2246 if ( .not. all( factor % sec_ary (imax-4:imax) == (/ 0, 0, 0, 0, 0 /) ) ) then
2247 call messagenotify( 'E', 'dc_scaledsec#modulo', &
2248 & 'factor must be smaller than 10^12' )
2249 end if
2250
2251 if ( sclsec == factor ) then
2252 result = zero_sec
2253 return
2254 end if
2255
2256 factor_scl % sec_ary(imin:-1) = 0
2257 factor_scl % sec_ary(imin-imin:imax) = factor % sec_ary(imin:imax+imin)
2258 factor_scl % flag_negative = factor % flag_negative
2259
2260 factor_dp = factor_scl
2261
2262 done = .false.
2263 move_down = 0.0_dp
2264 do i = imax, imin, -1
2265 move_down_index = i
2266 if ( abs(move_down) > dp_eps ) then
2267 sf_idx = i - imin
2268 if ( sf_idx > ubound(scale_factor_xx, 1) ) sf_idx = ubound(scale_factor_xx, 1)
2269 if ( sf_idx < lbound(scale_factor_xx, 1) ) sf_idx = lbound(scale_factor_xx, 1)
2270 if ( abs(factor_dp) > ( move_down + scale_factor ) * scale_factor_xx( sf_idx ) ) then
2271 done = .true.
2272 exit
2273 end if
2274 end if
2275
2276 sec_ary_mod(i) = &
2277 & mod( ( sclsec % sec_ary(i) + move_down ), factor_dp )
2278
2279 if ( abs(sec_ary_mod(i)) > dp_eps ) then
2280 move_down = sec_ary_mod(i) * scale_factor
2281 else
2282 move_down = 0.0_dp
2283 end if
2284 end do
2285
2286 if ( .not. done ) then
2287 do i = imin - 1, imin + imin, -1
2288 move_down_index = i
2289 if ( abs(move_down) > dp_eps ) then
2290 sf_idx = i - imin
2291 if ( sf_idx > ubound(scale_factor_xx, 1) ) sf_idx = ubound(scale_factor_xx, 1)
2292 if ( sf_idx < lbound(scale_factor_xx, 1) ) sf_idx = lbound(scale_factor_xx, 1)
2293 if ( abs(factor_dp) > ( move_down + scale_factor ) * scale_factor_xx( sf_idx ) ) then
2294 done = .true.
2295 exit
2296 end if
2297 end if
2298
2299 sec_ary_mod(i) = mod( move_down, factor_dp )
2300
2301 if ( abs(sec_ary_mod(i)) > dp_eps ) then
2302 move_down = sec_ary_mod(i) * scale_factor
2303 else
2304 move_down = 0.0_dp
2305 end if
2306 end do
2307 end if
2308
2309 result = move_down * scale_factor_xx(move_down_index)
2310 if ( move_down_index > imin - 1 ) then
2311 result % sec_ary(imin:move_down_index) = sclsec % sec_ary(imin:move_down_index)
2312 end if
2313
2314 result % flag_negative = .false.
2315
2316 if ( .not. result == zero_sec ) then
2317 if ( .not. sclsec % flag_negative .and. factor % flag_negative ) then
2318 result = - factor - result
2319 result % flag_negative = .not. sclsec % flag_negative
2320
2321 elseif ( sclsec % flag_negative .and. .not. factor % flag_negative ) then
2322 result = factor - result
2323 result % flag_negative = .not. sclsec % flag_negative
2324
2325 else
2326 result % flag_negative = sclsec % flag_negative
2327
2328 end if
2329 end if
2330
Provides kind type parameter values.
Definition dc_types.f90:55
real(dp), parameter, public dp_eps
Machine epsilon for dobule precision real number.
Definition dc_types.f90:97

References dc_types::dp_eps.


The documentation for this interface was generated from the following file: