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 7795649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:07:48+00:00 2026-06-01T23:07:48+00:00

I have this function in Fortran and i’m trying to recode it in C#

  • 0

I have this function in Fortran and i’m trying to recode it in C#

C **************************************************************** 
C    FUNCTION   POLY 
C***************************************************************** 
      FUNCTION POLY(N,A,X) 
      DIMENSION A(N) 
C
      POLY    = 0. 
      L       = N 
      DO 1 K  = 1,N 
      POLY    = POLY*X + A(L) 
1     L       = L-1 
      RETURN 
      END 
C***************************************************************** 

I found out that DIMENSION A(N) creates a vector of N values, but we already have a variable A from the function parameters, does this means that the array values all equal to A? If so then what is the use of A(N).
By the way can anyone just explain what does this function do so i can re-implement it in C#

  • 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-06-01T23:07:50+00:00Added an answer on June 1, 2026 at 11:07 pm
          FUNCTION POLY(N,A,X)      ! implicitly real (float) function poly(int n,int a,real x)
          DIMENSION A(N)            ! shape A as 1d array of n values in this scope
    C                               ! say nothing (blank comment)
          POLY    = 0.              ! initialise return variable to float value 0
          L       = N               ! set L (implicitly integer) to n
          DO 1 K  = 1,N             ! for(int k=1; k<=n; ++k)
          POLY    = POLY*X + A(L)   !    update return variable
    1     L       = L-1             !    decrement L
          RETURN                    ! return current value for poly
          END 
    

    so in c-like syntax:

    float poly(int n, int a, float x) {
        // redim a(n)
        float result = 0;
        int l = n;
        for(int k=1; k <= n; ++k) {
            result = result*x + a(l);
            --l;
        }
        return result;
    }
    

    The bit that doesn’t translate is redimensioning A as an array. In C you would pass a pointer and use it as an array, and in C++/C# you’d probably pass a vector-like structure with its own length property.

    In C#, using a list:

    float poly(List<float> coeffs, float x) {
        float result = 0;
        for(int i=coeffs.Count-1; i >= 0; --i) {
            result = result*x + coeff[i];
        }
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function in my Javascript Code that updates html fields with their
I have this function on my controller (Im using CodeIgniter) that reads the database,
I Have this function that allocating and initializing object : +(Item*)getItem:(NSString*)uid{ Item *file =
I have this function that I use to read a directory and get files
I have this function that checks a UK postcode. The problem is that it
I have this function that needs to be converted to a lambda statement: public
I have this old Fortran executable that can only be accessed through its GUI,
I have this: function test() { this.method = function () { $(html).mousemove(function(event) { console.log('~>
I have this: function test1() { this.count = 0; this.active = 0; this.enable =
I have this function which removes occurrences of a given element within the list

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.