MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Defining N for a new entity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66719] Defining N for a new entity
  • From: Giuseppe Bilotta <bilotta78 at hotpop.com>
  • Date: Sat, 27 May 2006 21:03:28 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

I'm try to build a Mathematica toolbox to work with Stolfi's affine
expression. Until now, I've had no problems: I use AffineExpression[c,
{{i, xi}, ...}] (where c and xi are Reals and the i are Integers) to
represent c + \sum xi e_i and I can define addition, multiplication,
quotient and everything else without any problems.

Recently, I've begun using these entities in more complex expression,
and in particular as elements of matrices to be fed to LinearSolve. 

In the specific context, LinearSolve seems to apply N to all of its
arguments, but as a side-effect of this the indices (i in the
expressions above) are turned into Reals, so that for example

AffineExpression[ .5, {{1, .2},{2, .1}}]

comes out as

AffineExpression[ .5, {{1., .2}, {2., .1}}]

This has aesthetical and functional disadvantages (my codes also
exploits the fact that the indices are integer), so I have to apply
Rationalize or some other such function to re-convert the indices into
Integers.

So I was looking for a way to tell Mathematica that applying N to an
AffineExpression should only actually apply it to c and xi, something
like

N[AffineExpression[c_, dev_]] :=
  AffineExpression[N[c], MapAt[N,#,{2}]&/@ dev]

but if I actually do this and then call 

AffineExpression[1, {{1, 1}}]
N[%]

the Mathematica kernel (5.2.0.0) dies without any message.

Does anybody have an idea of what could the reason be? And what could
I do as a workaround?

-- 
Giuseppe "Oblomov" Bilotta

Axiom I of the Giuseppe Bilotta
theory of IT:
Anything is better than MS


  • Prev by Date: Re: Re: Interval[{a,b}]-Interval[{a,b}] = 0?
  • Next by Date: Re: mathematica database link help
  • Previous by thread: Re: Discrete Functions... Signal Simulation... A Study Using Mathematica
  • Next by thread: Re: Defining N for a new entity