Home > Archive > Fortran > October 2004 > logical operator in fortran 90
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
logical operator in fortran 90
|
|
| joel GUERRERO 2004-10-20, 3:56 am |
| Hi,
I'm having the following problem with fortran 90 using logical
operators.
With the following statement I get the right answer. The statement is
as follows:
if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.&
y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ...
Now, I need to obtain exactly the opposite answer, so I suppose that I
just need to change the lo .eq. by .ne., but when I change the lo, I
get a totally different answer of what I was expecting for. How can I
solve this problem?
FYI I'm using cvf 6.6
Hope somebody can help me,
Greetings,
Joel
| |
| Dave Seaman 2004-10-20, 3:56 am |
| On 19 Oct 2004 20:22:29 -0700, joel GUERRERO wrote:
> Hi,
> I'm having the following problem with fortran 90 using logical
> operators.
> With the following statement I get the right answer. The statement is
> as follows:
> if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.&
> y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ...
> Now, I need to obtain exactly the opposite answer, so I suppose that I
> just need to change the lo .eq. by .ne., but when I change the lo, I
> get a totally different answer of what I was expecting for. How can I
> solve this problem?
The negation of
(1) (a .eq. b) .and. (c .eq. d)
is which of the following? (pick one:)
(2) (a .ne. b) .and. (c .ne. d)
(3) (a .ne. b) .or. (c .ne. d)
> FYI I'm using cvf 6.6
Makes no difference.
--
Dave Seaman
Judge Yohn's mistakes revealed in Mumia Abu-Jamal ruling.
<http://www.commoncouragepress.com/i...book&bookid=228>
| |
| Arjen Markus 2004-10-20, 3:56 am |
| Dave Seaman wrote:
>
> On 19 Oct 2004 20:22:29 -0700, joel GUERRERO wrote:
>
>
> The negation of
>
> (1) (a .eq. b) .and. (c .eq. d)
>
> is which of the following? (pick one:)
>
> (2) (a .ne. b) .and. (c .ne. d)
> (3) (a .ne. b) .or. (c .ne. d)
>
>
> Makes no difference.
>
The logical negation of (1) is (3). It is a rather elementary
exercise in logic :)
Regards,
Arjen
| |
| Tom Micevski 2004-10-20, 3:56 am |
| Dave Seaman wrote:
> On 19 Oct 2004 20:22:29 -0700, joel GUERRERO wrote:
>
>
>
>
>
> The negation of
>
> (1) (a .eq. b) .and. (c .eq. d)
>
> is which of the following? (pick one:)
>
> (2) (a .ne. b) .and. (c .ne. d)
> (3) (a .ne. b) .or. (c .ne. d)
or
(4) .not. ((a .eq. b) .and. (c .eq. d))
| |
|
| joel GUERRERO wrote:
>
> Now, I need to obtain exactly the opposite answer, so I suppose that I
> just need to change the lo .eq. by .ne., but when I change the lo, I
> get a totally different answer of what I was expecting for. How can I
> solve this problem?
Enroll in the appropriate course, or consult a textbook on "Boolean
algebra". In the meantime, short answer is: .not.(expr)
| |
|
| On Wed, 20 Oct 2004 at 06:24 GMT, Tom Micevski (aka Bruce)
was almost, but not quite, entirely unlike tea:
> Dave Seaman wrote:
> or
> (4) .not. ((a .eq. b) .and. (c .eq. d))
Which the compiler ought to optimise to the quickest to evaluate
expression anyway, so use the expression that makes most sense in the
context. Sometimes refactoring complex boolean expressions makes me
realise I was thinking about it the hard way when I came up with with
the original expression.
--
TimC -- http://astronomy.swin.edu.au/staff/tconnors/
Disclaimer: This post owned by the owner
| |
|
| Hi,
http://mathworld.wolfram.com/deMorgansLaws.html
Regards,
B52B
joel GUERRERO wrote:
> Hi,
> I'm having the following problem with fortran 90 using logical
> operators.
> With the following statement I get the right answer. The statement is
> as follows:
> if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.&
> y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ...
>
> Now, I need to obtain exactly the opposite answer, so I suppose that I
> just need to change the lo .eq. by .ne., but when I change the lo, I
> get a totally different answer of what I was expecting for. How can I
> solve this problem?
>
> FYI I'm using cvf 6.6
>
> Hope somebody can help me,
>
> Greetings,
> Joel
| |
|
|
"joel GUERRERO" <joegi.geo@yahoo.com> wrote in message
news:bc7de858.0410191922.2f7cd7d1@posting.google.com...
> Hi,
> I'm having the following problem with fortran 90 using logical
> operators.
> With the following statement I get the right answer. The statement is
> as follows:
> if(x_cor_split(j).eq.x_cor_split(repetidos(i,2)).and.&
> y_cor_split(j).eq.y_cor_split(repetidos(i,2))) then ...
>
> Now, I need to obtain exactly the opposite answer, so I suppose that I
> just need to change the lo .eq. by .ne., but when I change the lo, I
> get a totally different answer of what I was expecting for. How can I
> solve this problem?
>
> FYI I'm using cvf 6.6
>
> Hope somebody can help me,
>
> Greetings,
> Joel
As an extra comment :
If x_cor_split and/or y_cor_split are floating point numbers, it is not
recommended to be testing for equality, or non-equality, but within some
tolerance.
Les
|
|
|
|
|