?
Solved

Help with Fortran to C++ conversion

Posted on 2004-08-27
3
Medium Priority
?
313 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 2000 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

770 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