Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Defining N for a new entity

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66748] Re: Defining N for a new entity
  • From: "Scout" <Scout at nodomain.com>
  • Date: Mon, 29 May 2006 06:05:10 -0400 (EDT)
  • References: <e5aucq$nn4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Giuseppe Bilotta" <bilotta78 at hotpop.com>
news:e5aucq$nn4$1 at smc.vnet.net...
> 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
>

Hi Giuseppe,
have you already tried to define an upvalue for AffineExpression[] ?
Something like
    N[AffineExpression[c_, dev_]] ^:= AffineExpression[....]

For the other questions I don't know what's happening.
HTH,
    ~Scout~



  • Prev by Date: Re: Initialize a matrix in mathematica
  • Next by Date: Re: Initialize a matrix in mathematica
  • Previous by thread: Re: Defining N for a new entity
  • Next by thread: Re: Defining N for a new entity