Solved

Help with Fortran to C++ conversion

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

773 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