mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-21 20:33:55 +00:00
Estimated hours taken: 0.75 Use sub-modules to package up the modules in extras/complex_numbers into a single module. extras/complex_numbers/complex_lib.m: extras/complex_numbers/complex_numbers.m: Rename complex_lib.m as complex_numbers.m, and modify it to use sub-modules. extras/complex_numbers/*.m: extras/complex_numbers/tests/complex_test.m: extras/complex_numbers/samples/fft.m: Add `complex_numbers:' to all of the `:- module' and `:- import_module' declarations. extras/complex_numbers/Mmakefile: extras/complex_numbers/tests/Mmakefile: extras/complex_numbers/samples/Mmakefile: Modify to reflect the renaming from `complex_lib' to `complex_numbers'.
55 lines
1.6 KiB
Mathematica
55 lines
1.6 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% Copyright (C) 1997-1998 The University of Melbourne.
|
|
% This file may only be copied under the terms of the GNU Library General
|
|
% Public License - see the file COPYING.LIB in the Mercury distribution.
|
|
%---------------------------------------------------------------------------%
|
|
%
|
|
% File: float_imag.m.
|
|
% Main author: fjh.
|
|
% Stability: medium.
|
|
%
|
|
% This module provides binary operators on (float, imag).
|
|
%
|
|
% See also:
|
|
% complex.m, imag.m, float.m, imag_float.m.
|
|
%
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module complex_numbers:float_imag.
|
|
:- interface.
|
|
:- import_module float, complex_numbers:imag, complex_numbers:complex.
|
|
|
|
% addition
|
|
:- func float + imag = complex.
|
|
:- mode in + in = uo is det.
|
|
:- mode uo + uo = in is det.
|
|
|
|
% subtraction
|
|
:- func float - imag = complex.
|
|
:- mode in - in = uo is det.
|
|
:- mode uo - uo = in is det.
|
|
|
|
% multiplication
|
|
:- func float * imag = imag.
|
|
:- mode in * in = uo is det.
|
|
:- mode in * uo = in is det.
|
|
:- mode uo * in = in is det.
|
|
|
|
% division
|
|
:- func float / imag = imag.
|
|
:- mode in / in = uo is det.
|
|
:- mode in / uo = in is det.
|
|
:- mode uo / in = in is det.
|
|
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- implementation.
|
|
|
|
XR + im(YI) = cmplx(0.0 + XR, 0.0 + YI).
|
|
XR - im(YI) = cmplx(0.0 + XR, 0.0 - YI).
|
|
XR * im(YI) = im(XR * YI).
|
|
XR / im(YI) = im(0.0 - XR / YI).
|
|
|
|
%---------------------------------------------------------------------------%
|
|
%---------------------------------------------------------------------------%
|