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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:10:16+00:00 2026-05-24T03:10:16+00:00

Since I have been writing a big python program for my project. I have

  • 0

Since I have been writing a big python program for my project. I have another query of which I cant figure out the solution. Here is the code.

poly = [[k6,3], [k5,2], [k4,1], [k0,0]]

w = 5  # weight for rational bezier curve equation

def time() :
    with open(transcriptionFile, "r") as tFile :
            for line in tFile :
                li = line.split()
                if li :
                    start_time = (int(li[0]) / 10000000.)
                    end_time = (int(li[1]) / 10000000.) 
                    duration = ((int(li[1]) -int(li[0]))/10000000.)
                    print start_time,' ',end_time,' ',duration
                    poly_coeff(start_time, end_time, duration)

def poly_coeff(stime, etime, dur) :
    """The equation is k6 * u^3 + k5 * u^2 + k4 * u + k0 = 0. Computing the        coefficients of this equation."""
    """Substituting the required values we get the coefficients."""
    t_u = dur
    t0 = stime
    t3 = etime
    t1 = t2 = (stime + etime) / 2
    w0 = w1 = w2 = w3 = w
    k0 = w0 * (t_u - t0)
    k1 = w1 * (t_u - t1)
    k2 = w2 * (t_u - t2)
    k3 = w3 * (t_u - t3)
    k4 = 3 * (k1 - k0)
    k5 = 3 * (k2 - 2 * k1 + k0)
    k6 = k3 - 3 * k2 + 3 * k1 -k0 
    print k0, k1, k2, k3, k4, k5, k6

if __name__ == "__main__" :

    if len(sys.argv) != 2 : 
        Usage() 

    else :
        transcriptionFile = sys.argv[1]

        time()

    Newton(poly, 0.42, 1, 0)

There is a list of start time, end time and their duration. All of them are passed to the function poly_coeff() to generate the polynomial coefficients. There will be as many as there are in the list. Then for each polynomial generated, its corresponding coefficients should be passed as poly to Newton() function to carry out other calculations. And at the top, the polynomial is represented as poly. In poly, each k6, k5, k4 and k0 values generated should be passed. Of course it is not how to do but just to clear what I am trying to do. Please help. Thank you very much.

  • 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-24T03:10:16+00:00Added an answer on May 24, 2026 at 3:10 am

    The flow of your code was quite confusing. I assume that you want to calculate the poly for each line of your input file, then call Newton(poly, 0.42, 1, 0).

    I changed your time() function to take the filename as a parameter, and changed your poly_coeff method to return the poly you have calculated. Then in the for line in tFile: loop in time(), I get the result from poly_coeff() and pass that into Newton().

    Hopefully that is close to what you want to do…

    def time(fileName) :
        with open(fileName, "r") as tFile :
                for line in tFile :
                    li = line.split()
                    if li :
                        start_time = (int(li[0]) / 10000000.)
                        end_time = (int(li[1]) / 10000000.) 
                        duration = ((int(li[1]) -int(li[0]))/10000000.)
                        print start_time,' ',end_time,' ',duration
    
                        poly = poly_coeff(start_time, end_time, duration)
                        Newton(poly, 0.42, 1, 0)
    
    def poly_coeff(stime, etime, dur) :
        """The equation is k6 * u^3 + k5 * u^2 + k4 * u + k0 = 0. Computing the        coefficients of this equation."""
        """Substituting the required values we get the coefficients."""
        w = 5  # weight for rational bezier curve equation
    
        t_u = dur
        t0 = stime
        t3 = etime
        t1 = t2 = (stime + etime) / 2
        w0 = w1 = w2 = w3 = w
        k0 = w0 * (t_u - t0)
        k1 = w1 * (t_u - t1)
        k2 = w2 * (t_u - t2)
        k3 = w3 * (t_u - t3)
        k4 = 3 * (k1 - k0)
        k5 = 3 * (k2 - 2 * k1 + k0)
        k6 = k3 - 3 * k2 + 3 * k1 -k0 
        print k0, k1, k2, k3, k4, k5, k6
    
        return [[k6,3], [k5,2], [k4,1], [k0,0]]
    
    
    if __name__ == "__main__" :
        if len(sys.argv) != 2 : 
            Usage()
        else :
            transcriptionFile = sys.argv[1]
    
            time(transcriptionFile)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been pulling my hair out about this since Friday and I am
I have been writing a program that watches a directory and when files are
I have been trying to figure out the best way to start working on
I have a C++/Obj-C background and I am just discovering Python (been writing it
A project I have been working on for the past year writes out log
I have been programming since 1999 for work and fun. I want to learn
I have been programming in Java since 2004, mostly enterprise and web applications. But
I have been developing in asp.net since its existence (also classic asp before that)
I have been posting on my blog http://www.prashantraju.com/ since Jan 2010 however for some
We have been using Rational Rose 2000 or so for modeling since i guess

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.