Subject: [FFC-dev] Absolute value difficulties.

From: Marie Rognes <[email-masked]>
Date: Thu, 20 Sep 2007 17:54:50 +0200

We seem to have the following slightly suboptimal solution:

    Python 2.4.3 (#1, Feb  6 2007, 22:40:17)
    [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
     >>> import ffc
     >>> ffc.abs(-1)
    -1.0

This is relatively easy to fix.

The next problem is

     >>> ffc.abs(1) < 0.001
    True

which is a bit more puzzling for me in itself and in how to fix.

Anyone want to take a look?

--
Marie, who just spent a couple of hours puzzled over boundary conditions ;)

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 20 Sep 2007 18:26:48 +0200

> This is relatively easy to fix.

yes

> Anyone want to take a look?

ffc.abs(1)

returns a Form
try
ffc.abs(1).__doc__

what you could do is
f = ffc.Form(1)
f.monomials[0].numeric < 0.001
which will be false

Kristian

> _______________________________________________
> FFC-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/ffc-dev
>

---

From: Marie Rognes <[email-masked]>
Date: Thu, 20 Sep 2007 19:01:33 +0200

> f.monomials[0].numeric < 0.001
In other words - the most sensible thing to do would be to implement 
less-than and greather-than for Forms in the above manner?

Will do, unless anyone objects.

--
Marie

---

From: Kristian Oelgaard <[email-masked]>
Date: Thu, 20 Sep 2007 19:33:34 +0200

> less-than and greather-than for Forms in the above manner?

Yes, I think so.
 
> Will do, unless anyone objects.

I don't mind

Kristian

---

From: Anders Logg <[email-masked]>
Date: Thu, 20 Sep 2007 21:57:52 +0200

Looks good, but why do you need this?

/Anders

---

From: Marie Rognes <[email-masked]>
Date: Thu, 20 Sep 2007 23:38:27 +0200

> Looks good, but why do you need this?

For instance after doing:

    from dolfin import *
    a = -1.0
    f = abs(a)
   
f is now a Form...

--
Marie

---

From: Anders Logg <[email-masked]>
Date: Fri, 21 Sep 2007 00:13:40 +0200

ok, now I see the problem...

We should probably not be messing with Python builtins like abs().

How about renaming it modulus?

/Anders

---

From: Marie Rognes <[email-masked]>
Date: Fri, 21 Sep 2007 11:03:23 +0200

> We should probably not be messing with Python builtins like abs().

Yes, I think that is a good idea to prevent trouble.

> How about renaming it modulus?

Sounds good to me.

--
Marie

>>>> In other words - the most sensible thing to do would be to 
>>>> implement less-than and greather-than for Forms in the above manner?
>>>>