Solved

Help with Fortran to C++ conversion

Posted on 2004-08-27
3
290 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add mobile access to browser application 3 133
java ^ examples 8 57
post4 challenge 28 83
C++ :Change value from  DisableCMD registry 4 12
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This article will show, step by step, how to integrate R code into a R Sweave document
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.
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now