mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-27 23:34:52 +00:00
Estimated hours taken: 1 Branches: main, release Cleanups for the complex numbers library. extras/complex_numbers/*.m: extras/complex_numbers/samples/fft.m: extras/complex_numbers/tests/complex_test.m: Convert these modules to four-space indentation. Conform to our current coding standard.
62 lines
1.9 KiB
Mathematica
62 lines
1.9 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
% vim: ft=mercury ts=4 sw=4 et
|
|
%-----------------------------------------------------------------------------%
|
|
% Copyright (C) 1997-1998, 2001, 2004-2006 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 complex_numbers.complex.
|
|
:- import_module complex_numbers.imag.
|
|
|
|
:- import_module float.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
% Addition.
|
|
%
|
|
:- func float + imag = complex.
|
|
:- mode in + in = uo is det.
|
|
|
|
% Subtraction.
|
|
%
|
|
:- func float - imag = complex.
|
|
:- mode in - in = uo is det.
|
|
|
|
% Multiplication.
|
|
%
|
|
:- func float * imag = imag.
|
|
:- mode in * in = uo is det.
|
|
|
|
% Division.
|
|
%
|
|
:- func float / imag = imag.
|
|
:- mode in / in = uo 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).
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
%-----------------------------------------------------------------------------%
|