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: [mg66762] Re: Defining N for a new entity
  • From: Giuseppe Bilotta <bilotta78 at hotpop.com>
  • Date: Mon, 29 May 2006 06:06:10 -0400 (EDT)
  • References: <200605280103.VAA23345@smc.vnet.net> <e5bsuq$afo$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On Sun, 28 May 2006 10:10:34 +0000 (UTC), Carl K. Woll wrote:

> Giuseppe Bilotta wrote:
>> 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?
> 
> One idea is to use the attribute NHoldRest (or if you change your data 
> structure, NHoldFirst). For example:
> 
> SetAttributes[AffineExpression, NHoldRest]
> 
> In[42]:= N[AffineExpression[.5, {{1, .2}, {2, .1}}]]
> 
> Out[42]= AffineExpression[0.5, {{1, 0.2}, {2, 0.1}}]

Thank you very much, this does the trick. It has the rather small
side-effect of preventi N from working on the coefficients
(N at AffineExpression[.5,{{1,Pi/6}}] will not numerize Pi/6), but it's
good enough for my application.

Do you have any ideas on why the Mathematica kernel dies without a
message?

-- 
Giuseppe "Oblomov" Bilotta

"E la storia dell'umanità, babbo?"
"Ma niente: prima si fanno delle cazzate,
 poi si studia che cazzate si sono fatte"
(Altan)
("And what about the history of the human race, dad?"
 "Oh, nothing special: first they make some foolish things,
  then you study what foolish things have been made")


  • Prev by Date: RE: Initialize a matrix in mathematica
  • Next by Date: Re: Behavior of ReplaceAll with Computed Results from a Conditional Test
  • Previous by thread: Re: Defining N for a new entity
  • Next by thread: Re: Defining N for a new entity