Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001817OCamlOCaml generalpublic2003-09-05 03:312013-08-30 22:50
Reporteradministrator 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001817: Complex infinity/nan field values
DescriptionFull_Name: william margolis
Version: 3.06
OS: linux (suse 8.1)
Submission from: adsl-63-199-206-139.dsl.lsan03.pacbell.net (63.199.206.139)


I love the Complex module, BUT:


   Objective Caml version 3.06

# 1/0;;
Exception: Division_by_zero.
# 1.0/.0.;;
-: float = inf.
# Complex.div Complex.one Complex.zero;;
-:: Complex.t = {Complex.re = nan; Complex.im = nan.}

I understand why this is occuring, according to the standard sequencing through
the complex division algorithm. But, for people working on the Rieman sphere,
it would be very, very pleasant if 1/0 could register as, say {Complex.re =
infinity; Complex.im = 0.} or something similar !?

This would certainly please extended-complex-plane people. (We expect a/0 = an
infinity type, not an nan...)

In any case, my desire is that I may be able to distinguish in the complex case
between nan and infinity cases, without having to create, say:

type sphere = INF | C of float * float ;;

and do all the argument matching comparisons each time.

Is there an easy/efficient implementation !?


Tagspatch
Attached Files? file icon complex_test.ml [^] (8,547 bytes) 2007-11-25 20:25 [Show Content]

- Relationships
related to 0004748resolved Complex +-0. 

-  Notes
(0004348)
Christophe Troestler (reporter)
2007-11-25 01:04
edited on: 2007-12-01 11:04

It seems that the better one can do is to follow the ISO/IEC 9899:1999 standard, annex G (IEC 60559-compatible complex arithmetic (informative), pages 465–478. ANSI, 1999.). Then

# Complex.div Complex.one Complex.zero;;
- : Complex.t = {re = infinity; im = nan}

which is an infinity because a complex number with any infinite component is considered infinite (the only complex NaN is { re = nan; im = nan }. I have uploaded the file "complex_test.ml" with an implementation of mul and div.

See also: ftp://ftp.win.ua.ac.be/pub/preprints/03/criticism.pdf [^]


- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2007-11-25 01:04 Christophe Troestler Note Added: 0004348
2007-11-25 20:25 Christophe Troestler File Added: complex_test.ml
2007-12-01 11:04 Christophe Troestler Note Edited: 0004348
2009-08-19 14:59 xclerc Relationship added related to 0004748
2013-08-30 22:50 doligez Tag Attached: patch


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker