Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Help with Fortran to C++ conversion

Posted on 2004-08-27
3
302 Views
Last Modified: 2013-11-08
Hello, i have this in fortran:

       LOGICAL LMASK(6)

       DO 110 J=1,6
 110      LMASK(J) = .TRUE.

         DO 130 K=1,6
  130       IF(LMASK(K)
     &     .AND.( (.NOT.LMASK(1)) .OR. (ABSA(K).GE.ABSA(1)) )
     &     .AND.( (.NOT.LMASK(2)) .OR. (ABSA(K).GE.ABSA(2)) )
     &     .AND.( (.NOT.LMASK(3)) .OR. (ABSA(K).GE.ABSA(3)) )
     &     .AND.( (.NOT.LMASK(4)) .OR. (ABSA(K).GE.ABSA(4)) )
     &     .AND.( (.NOT.LMASK(5)) .OR. (ABSA(K).GE.ABSA(5)) )
     &     .AND.( (.NOT.LMASK(6)) .OR. (ABSA(K).GE.ABSA(6)) )  )
     &                          IPIV = K

         LMASK(IPIV) = .FALSE.

I don't know how would you express that if statement in C++.

Thank You
0
Comment
Question by:Mad_Angel
  • 3
3 Comments
 
LVL 11

Accepted Solution

by:
bcladd earned 500 total points
ID: 11917679
bool LMask[6];
for (int k = 0; k != 6; ++i)
  LMask[k] = true;

for (int k = 0; k != 6; ++i)
  if (LMask[k]
      && (!LMask[0] || (Absa[k] >= Absa[0]))
      && (!LMask[1] || (Absa[k] >= Absa[1]))
      && (!LMask[2] || (Absa[k] >= Absa[2]))
      && (!LMask[3] || (Absa[k] >= Absa[3]))
      && (!LMask[4] || (Absa[k] >= Absa[4]))
      && (!LMask[5] || (Absa[k] >= Absa[5])))
    ipiv = k;

LMask[k] = false;

This assumes that ABSA is another array and that you have it defined in your C++; that that out of context I could have otherthings that are not quite right but the basics should be there.
0
 
LVL 11

Expert Comment

by:bcladd
ID: 11917688
Oh, yeah, declare

int ipiv;

before the second loop starts.

-bcl
0
 
LVL 11

Expert Comment

by:bcladd
ID: 11917692
And the last line of the code should read

LMask[ipiv] = false;

-bcl
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best book to learn C++ 4 84
Microsoft C++ code failing in executable that worked 9 108
Re-position the objects 7 117
C++ help/ Toy problem 19 30
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question