Документ взят из кэша поисковой машины. Адрес оригинального документа : http://crydee.sai.msu.ru/f90/code/intv_ari.f90
Дата изменения: Fri Aug 30 10:58:52 1996
Дата индексирования: Mon Oct 1 21:55:48 2012
Кодировка:
MODULE INTERVAL_ARITHMETICS
TYPE INTERVAL
REAL LOWER, UPPER
END TYPE INTERVAL
INTERFACE OPERATOR (+)
MODULE PROCEDURE INTERVAL_ADDITION
END INTERFACE
INTERFACE OPERATOR (-)
MODULE PROCEDURE INTERVAL_SUBTRACTION
END INTERFACE
INTERFACE OPERATOR (*)
MODULE PROCEDURE INTERVAL_MULTIPLICATION
END INTERFACE
INTERFACE OPERATOR (/)
MODULE PROCEDURE INTERVAL_DIVISION
END INTERFACE
CONTAINS
FUNCTION INTERVAL_ADDITION(A, B)
TYPE(INTERVAL), INTENT(IN) :: A, B
TYPE(INTERVAL) :: INTERVAL_ADDITION
INTERVAL_ADDITION%LOWER = A%LOWER + B%LOWER
INTERVAL_ADDITION%UPPER = A%UPPER + B%UPPER
END FUNCTION INTERVAL_ADDITION

FUNCTION INTERVAL_SUBTRACTION(A, B)
TYPE(INTERVAL), INTENT(IN) :: A, B
TYPE (INTERVAL) :: INTERVAL_SUBTRACTION
INTERVAL_SUBTRACTION%LOWER = A%LOWER - B%UPPER
INTERVAL_SUBTRACTION%UPPER = A%UPPER - B%LOWER
END FUNCTION INTERVAL_SUBTRACTION

FUNCTION INTERVAL_MULTIPLICATION(A, B)
! POSITIVE NUMBERS ASSUMED
TYPE(INTERVAL), INTENT(IN) :: A, B
TYPE (INTERVAL) :: INTERVAL_MULTIPLICATION
INTERVAL_MULTIPLICATION%LOWER = A%LOWER * B%LOWER
INTERVAL_MULTIPLICATION%UPPER = A%UPPER * B%UPPER
END FUNCTION INTERVAL_MULTIPLICATION
FUNCTION INTERVAL_DIVISION(A, B)
! POSITIVE NUMBERS ASSUMED
TYPE(INTERVAL), INTENT(IN) :: A, B
TYPE(INTERVAL) :: INTERVAL_DIVISION
INTERVAL_DIVISION%LOWER = A%LOWER / B%UPPER
INTERVAL_DIVISION%UPPER = A%UPPER / B%LOWER
END FUNCTION INTERVAL_DIVISION
END MODULE INTERVAL_ARITHMETICS