Thread: python to c

  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    39

    python to c

    Hi,

    I know a little bit of python and am now starting to learn c. In python if I use numpy I have most things provided to me. For example If I want a sequence of 100 number between 1 and 10 I would just use numpy.linspace(1,10,100) . Now I know that I can quite easily do the same myself with a for loop, but I was wondering that it is something so often used would there be functions that do that for you in c. My other similar questions are that If I have two arrays and I want to append one to the end of the other is there a function in some library that does it.

    Consider this 1,2,3,4,5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.1,10.2,10. 3 ............. 14.9,15

    The sequence from 1 to 15 is not equally spaced. Trivial to implement in python. I can do it in c with by defining a function and a for loop. Is C difficult because you have to do everything from scratch? Something like the sequence above is what I need very frequently it be annoying to write a code for it each time. If you know numerical libraries in C that do similar things as numpy please let me know. I am aware of gsl which is similar to scipy.

    thanks guys.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by ali.franco95 View Post
    Is C difficult because you have to do everything from scratch? Something like the sequence above is what I need very frequently it be annoying to write a code for it each time. If you know numerical libraries in C that do similar things as numpy please let me know.
    So your complaint is that you have a library to do that for you in python, but that you have to rewrite it every time in C? Why don't you just write yourself a library of useful functions and call them when you need them? You know...just like you are doing in python with "numpy". Someone had to write that library for you to use.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Sep 2011
    Posts
    39
    I see that last sentence does sound like a complain, disregard it. I am more concerned about spending time on doing things that would have already been done by other people and because I am an amateur my version is most likely going to be less elegant/efficient. All I wanted was for some one to tell me, sorry son, you got to do it yourself. no easy meals in c.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Why aren't you looking for the C implementation? With a little luck, it'll already be done!
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Python --> C
    By Macha in forum C Programming
    Replies: 71
    Last Post: 05-28-2010, 06:18 PM
  2. python c api
    By ralu. in forum C Programming
    Replies: 0
    Last Post: 03-01-2009, 01:19 PM
  3. Python
    By Xterria in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 05-05-2002, 04:08 PM
  4. Python help. Anyone?
    By Potato_Tempest in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 01-28-2002, 03:26 PM
  5. Python
    By Eber Kain in forum Game Programming
    Replies: 0
    Last Post: 08-30-2001, 08:25 PM