| Re: [eigen] Custom complex type | 
[ Thread Index | 
Date Index
| More lists.tuxfamily.org/eigen Archives
] 
- To: eigen@xxxxxxxxxxxxxxxxxxx
 
- Subject: Re: [eigen] Custom complex type
 
- From: Gael Guennebaud <gael.guennebaud@xxxxxxxxx>
 
- Date: Tue, 7 Jun 2011 20:43:45 +0200
 
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=gamma;        h=domainkey-signature:mime-version:in-reply-to:references:from:date         :message-id:subject:to:content-type:content-transfer-encoding;        bh=YbrSh/xVvsfdosF2CD5+cSjA0k0WFYTOce+epxosOE0=;        b=K6yV3ciBAPs0Tq/l19arfU26G/ueII1F1LNxCR7uapj/+5YNYrOKC1JPrbICBOoruq         uxQ84MEzJu/IaO3v/qMHqtwyGZeXv2knIQOb4xiLxUNQr5qYFOahUXTLBmDRWmNl6oVV         ves71HV0jYyaJkh4xIBFo/HZhiTx7W9TvgRZE=
 
- Domainkey-signature: a=rsa-sha1; c=nofws;        d=gmail.com; s=gamma;        h=mime-version:in-reply-to:references:from:date:message-id:subject:to         :content-type:content-transfer-encoding;        b=b/dsJSdLurq5jggHJrsYkbaoYWiwfg2F0MGsORLdAgDwjIhI6G2w4bncP47b9gnf0p         +PxGsF48c2PLTIOUBM1h5fYbaLFTqUMsyIumckJoJaWBBFkx0tYvDVNq6/bDtOoi+SN5         Jfufh4ja8FVOZjWZYKKe7DDkl05fUkoB9JE6g=
 
Hi Pavel,
in theory you should be able to write your own mpcomplex class, and
define NumTraits<mpcomplex>::IsComplex to true as long as you
implement a STD compatible API.
gael
On Tue, Jun 7, 2011 at 8:04 AM, Pavel Holoborodko <pavel@xxxxxxxxxxxxxxx> wrote:
> Hello,
> Eigen's magicians, please advise on how to implement custom complex type for
> smooth integration with Eigen.
> I plan to create multi-precision C++ complex scalar class based on
> MPC: http://www.multiprecision.org/index.php?prog=mpc.
> MPC is cousin of MPFR from the same authors - http://mpfr.org.
> There are two possible ways to proceed:
> (1).  Add template specialization for std::complex<mpfr::mpreal>.
> (2).  Create own scalar class something like mpcomplex based on low-level
> MPC.
> Second option seems attractive from optimization point of view - minimum
> overhead, no conversion mpreal <-> MPC low level stuff is required.
> There is only one problem - will it be possible to integrate such complex
> type with Eigen?
> Documentation on NumTraits says:
> "An enum value IsComplex. It is equal to 1 if T is a std::complex type, and
> to 0 otherwise."
> Does it mean that only std::complex<T> custom complex types are supported in
> Eigen?
> If yes, do I need to provide something besides
> NumTraits<std::complex<mpreal> > specialization?
> Thanks in advance,
> Pavel.
>
>
>
>