Solved

Help with Fortran to C++ conversion

Posted on 2004-08-27
3
303 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
[X]
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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

726 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