Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:07:45+00:00 2026-05-29T21:07:45+00:00

I am converting some Fortran90 code to C#. I have some knowledge of Fortran77

  • 0

I am converting some Fortran90 code to C#. I have some knowledge of Fortran77 but am not familiar with Fortran90. I have run across the following line of code that I am not certain how to translate.

C1 = real(product((/(-1,i1=1,m-1)/))*product((/(i1,i1=2,m)/)))

I am thinking this should be converted as:

int product1 = -1; int product2 = 1;
for (int i1 = 1 ; i1 <= (m-1); i1++)
{
    product1 *= -1;
}
for (int i2 = 2, i2 <= m; i2++)
{
    product2 *= i2;
}
float C1 = (float)(product1 * product2);

My uncertainty stems from the fact that there exists an implied do loop construction for initializing arrays; i.e.

A = (/2*I, I = 1,5/)

but I have never seen the word “product” used as in the Fortran statement in question. I know there is an intrinsic function for vector or matrix multiplication called PRODUCT but “product” is not an array in the code I am working with and the syntax of the intrisic function PRODUCT uses MASK so clearly my statement is not using this function.

Any insight or help would be greatly appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:07:49+00:00Added an answer on May 29, 2026 at 9:07 pm

    If you decompose the parts and print them, you’ll notice these are simply terms created using concise vectorized terms:

    ! given: (/(expr, start, end)/)
    !
    ! (/(-1, i1=1, m-1)/) = vector, -1 repeated m-1 times
    !
    ! (/(i1, i1=2, m)/)   = vector, 2..m
    !
    ! Both are vectors with m-1 terms
    

    The other thing to note is that product() does not require 3 arguments. The second argument (the dimension to use) and the third argument (an array mask) are not required.

    At this point it becomes clear that the first product is actually -1m-1 and the second product is m!.

    So, a proper (but not necessarily efficient) translation could be:

    // product((/(-1,i1=1,m-1)/)) => -1^m-1
    double i = (m % 2 == 0 ? -1 : 1);
    
    // product((/(i1,i1=2,m)/))   => m!
    double mfact = i;
    for (int jj = 2; jj < m; ++jj)
    {
        mfact *= jj;
    } // C1 = mfact;
    

    Succinct, close in “spirit” with the F90, but hardly efficient:

    double i = (m % 2 == 0 ? -1 : 1);
    double C1 = Enumerable.Range(2, m)
                          .Aggregate(i, (x, y) => x * y);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got some C# code that I'm converting to Objective-C. In C# I would
I am converting some functioning Haskell code that uses Parsec to instead use Attoparsec
I am converting some Qt project files (.pro) that run on Linux and Mac
I am having trouble converting some code from VB6 to VB.NET (I don't have
I'm converting some old PHP 4.x code for PHP 5.3. I've come across the
I am tasked with converting some Python code to Java. I have some experience
I am converting some code from Perl into .NET. I have this s/// pattern
I'm converting some code that currently uses an XmlWriter to create a document to
I'm converting some JavaScript code to jQuery and have come to a halt, Heres
I am converting some code from another language to python. That code reads a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.