[SciPy-user] Boolean Algebra

Michael Hearne mhearne@usgs....
Tue Aug 21 10:27:18 CDT 2007


Perez - I actually can't find any decent on-line tutorials describing  
this, but booleans in Python are not done using "&" and "|" symbols,  
but the words "and" and "or".

The library reference has this page:
http://docs.python.org/lib/boolean.html

You may want to buy an introductory Python book - I have OReilly's  
"Learning Python", and it's pretty good for figuring out the basics.

--Mike Hearne
On Aug 21, 2007, at 6:08 AM, Perez Kawumi wrote:

> Hi,
> Can someone please tell me where I can find any information  
> regarding how boolean algebra is used in python. This is the piece  
> of code im trying to write I have just used dummy variables for the  
> matrices and the other different values. Just want to know if there  
> is anything I should watch out for when I get the actual values for  
> the different matrices coz they will most probably be floating  
> point numbers.
>
> And I'm trying to return dof_flag at the end. I initially want all  
> the elements of the vector dof_flag = 1. Is this the right way of  
> doing this or is there any other smarter way of doing this coz I  
> want to return dof_flag as a vector at the end
> Thanks
>
> dof_flag = []
> dof_flag = ones((1,5))
> NUM_EDGES = 2
> b=1
> print dof_flag
> node1 =[]
> print node1
> node2 =[]
> print node2
> EDGES =ones((3,4))
> NODE_COORD =ones((3,4))
> eps = 3
> print EDGES
> print NODE_COORD
>
> for i_edge in range(0, NUM_EDGES):
>         node1 = EDGES[i_edge,1]
>         print node1
>         node2 = EDGES[i_edge,2]
>         print node2
> #i.e. y =0
>         if (abs(NODE_COORD[node1,2]) < eps) & (abs(NODE_COORD 
> [node2,2]) <eps):
>             dof_flag[i_edge] = 0
>
> #i.e. y =b
>         if abs((NODE_COORD[node1,2])-b) < eps & abs((NODE_COORD 
> [node2,2])-b) <eps:
>             dof_flag[i_edge] = 0
> #i.e. x =0
>         if abs(NODE_COORD[node1,1]) < eps & abs(NODE_COORD 
> [node2,1]) <eps:
>             dof_flag[i_edge] = 0
> #i.e. x =a
>         if abs((NODE_COORD(node1,1))-a) < eps & abs((NODE_COORD 
> (node2,1))-a) <eps:
>             dof_flag[i_edge] = 0
>
>
>
>
> To help you stay safe and secure online, we've developed the all  
> new Yahoo! Security Centre.
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user




------------------------------------------------------
Michael Hearne
mhearne@usgs.gov
(303) 273-8620
USGS National Earthquake Information Center
1711 Illinois St. Golden CO 80401
Senior Software Engineer
Synergetics, Inc.
------------------------------------------------------


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20070821/8b2dda9a/attachment.html 


More information about the SciPy-user mailing list