Mathematica 9 is now available
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: [mg66775] Re: Defining N for a new entity
  • From: Giuseppe Bilotta <bilotta78 at hotpop.com>
  • Date: Tue, 30 May 2006 05:48:11 -0400 (EDT)
  • References: <e5aucq$nn4$1@smc.vnet.net> <e5ehbc$7kt$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Mon, 29 May 2006 10:10:52 +0000 (UTC), Scout wrote:

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

Sadly, the kernel dies regardless of whether I define it as an upvalue
or not. The strange thing is that this is something related to the
internals of N:

MyN[AffineExpression[c_, dev_?MatrixQ]] ^:=
  AffineExpression[N[c], MapAt[N,#, 2] & /@ dev];
N[AffineExpression[c_, dev_?MatrixQ]] ^:=
  AffineExpression[N[c], MapAt[N, #, 2] & /@ dev];
AffineExpression[1/6, {{2, 1/3}}]
MyN[%]
N[%%]

The strange thing is that the kernel dies without a message or
anything.

-- 
Giuseppe "Oblomov" Bilotta

"I'm never quite so stupid
 as when I'm being smart" --Linus van Pelt


  • Prev by Date: Re: Mixed tensors as arguments of compiled functions
  • Next by Date: Re: Extending Plus very slow
  • Previous by thread: Re: Defining N for a new entity
  • Next by thread: Figures and LaTeX