Files
mercury/tests/mmc_make/lib/imag.m
Simon Taylor 886d2ae474 Make it easier to use shared libraries on x86 with
Estimated hours taken: 20
Branches: main

Make it easier to use shared libraries on x86 with
`mmc --make'.

There is now a third kind of object file, `.lpic_o'.
These files are compiled with `--pic-reg' but not with
CFLAGS_FOR_PIC, so they can be linked with shared Mercury
libraries.

On x86, executables which are linked with shared Mercury
libraries now depend on $(main_module.lpic_os), not
$(main_module.os).

This doesn't work with Mmake because ml doesn't know
which libraries are Mercury libraries, so it can't
link with the static versions of those libraries if
MERCURY_LINKAGE is set to "static".

configure.in:
bindist/bindist.configure.in:
bindist/bindist.build_vars.in:
	Work out whether `.lpic_o' files are needed.

compiler/modules.m:
	Add `.lpic_o' to the list of grade or architecture
	dependent files.

NEWS:
README.Linux:
compiler/options.m:
doc/user_guide.texi:
	Document MERCURY_LINKAGE, LINKAGE, --linkage,
	--mercury-linkage and -R.

compiler/options_file.m:
compiler/make.program_target.m:
	Handle LINKAGE and MERCURY_LINKAGE variables.

	Allow LIBGRADES, LINKAGE and MERCURY_LINKAGE to be target-specific.

scripts/mmc.in:
	Set up the default linkage using the MERCURY_LINKAGE
	variable.

compiler/compile_target_code.m:
	Build `.lpic_o' files.

	Work out which type of object files to link with.

	When linking statically with Mercury libraries,
	find the absolute pathname for the `.a' file
	for each Mercury library, and pass that to ml,
	rather than just using `-lname'.

	Pass `-R' options to ml for each `-R' option to mmc.

compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile.m:
	Specify which type of object files to build.

compiler/make.program_target.m:
compiler/make.module_target.m:
	Make sure all generated object files are cleaned up.

compiler/prog_io.m:
	Add a better message for files which can't be found.

compiler/make.util.m:
	Add `.lpic_o' to the list of extensions.

compiler/Mmakefile:
profiler/Mmakefile:
deep_profiler/Mmakefile:
	Pass `--linkage shared' to mmc (`--shared' is in MLFLAGS).

tests/Mmakefile:
tests/mmc_make/Mmakefile:
tests/mmc_make/Mercury.options:
tests/mmc_make/complex_test.{m,exp}:
tests/mmc_make/hello.{m,exp}:
	Test `mmc --make'.

tests/lib/complex*.m:
	The complex numbers library from the extras distribution,
	for use in the mmc_make tests.
2003-01-23 00:24:20 +00:00

78 lines
2.1 KiB
Mathematica

%---------------------------------------------------------------------------%
% Copyright (C) 1997-1998,2001 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: imag.m.
% Main author: fjh.
% Stability: medium.
%
% Imaginary numbers.
%
% There are several reasons for supporting a separate type for imaginary
% numbers rather than just treating them as a special case of complex
% numbers. It is sometimes more convenient, and can be slightly more
% efficient. But perhaps the most important reason is to get correct
% handling of infinity and not-a-number on platforms that support IEEE
% floating point.
%
% Note that the overloaded versions of the binary operators which
% provide mixed type arithmetic are defined in different modules.
%
% See also:
% float.m, imag_float.m, float_imag.m,
% complex.m, imag_complex.m, complex_imag.m.
%
%---------------------------------------------------------------------------%
:- module complex_numbers:imag.
:- interface.
:- import_module float.
:- type imag ---> im(float).
:- func i = imag. % i = sqrt(-1)
:- func j = imag. % another name for `i'
% addition
:- func imag + imag = imag.
:- mode in + in = uo is det.
% subtraction
:- func imag - imag = imag.
:- mode in - in = uo is det.
% multiplication
:- func imag * imag = float.
:- mode in * in = uo is det.
% division
:- func imag / imag = float.
:- mode in / in = uo is det.
% unary plus
:- func + imag = imag.
:- mode + in = uo is det.
% unary minus
:- func - imag = imag.
:- mode - in = uo is det.
%---------------------------------------------------------------------------%
:- implementation.
i = im(1.0).
j = i.
+im(X) = im(X + 0.0).
-im(X) = im(-X).
im(X) + im(Y) = im(X + Y).
im(X) - im(Y) = im(X - Y).
im(X) * im(Y) = 0.0 - X * Y.
im(X) / im(Y) = X / Y.
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%