472,337 Members | 1,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,337 software developers and data experts.

using Numeric in C++

I have made a program in "Python" which imports Numeric and calls the
function

ones_array = Numeric.ones(blah,blah)

i see that C++ has a <numeric> library and i was wondering where the
"ones" function is ... in that library...

please help

Jul 23 '05 #1
4 1773
"GujuBoy" <di*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com
I have made a program in "Python" which imports Numeric and calls the
function

ones_array = Numeric.ones(blah,blah)

i see that C++ has a <numeric> library and i was wondering where the
"ones" function is ... in that library...

Since this is not a Python group, perhaps you would like to tell us what the
"ones" function does. I would not assume that the common use of the word
"numeric" implies common functionality between Python and the C++ library.

--
John Carson

Jul 23 '05 #2
The 'ones'-function in Numeric creates a new array of a given
size/dimension and fills it with the value '1'.

A simple C++ version of this code could be the following:

#import <cstring>

double [] ones_array = new double[blah] // initialize an array with
'blah' length
memset(ones_array, 1, sizeof(double))

If you want a more advanced array class, you might want to take a look
at the STL vector-class.

--
Reidar

Jul 23 '05 #3
* re******@gmail.com:
[mostly incoherent] The 'ones'-function in Numeric creates a new array of a given
size/dimension and fills it with the value '1'.
There is no 'ones' function and there is no Numeric in standard C++.

A simple C++ version of this code could be the following:

#import <cstring>
This is not standard C++.

double [] ones_array = new double[blah] // initialize an array with
This is not standard C++.

memset(ones_array, 1, sizeof(double))
This is Undefined Behavior.

If you want a more advanced array class, you might want to take a look
at the STL vector-class.


That's good advice.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #4
re******@gmail.com wrote:
The 'ones'-function in Numeric creates a new array of a given
size/dimension and fills it with the value '1'.

A simple C++ version of this code could be the following:

#import <cstring>

double [] ones_array = new double[blah] // initialize an array with
'blah' length
memset(ones_array, 1, sizeof(double))


double *ones_array = new double[blah];
fill(ones_array, ones_array + blah, 1.0);
or:
fill_n(ones_array, blah, 1.0);

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Phil | last post by:
Hi, I don't understand this strange behaviour: I compile this code : #include <Python.h> #include"Numeric/arrayobject.h" static PyObject...
0
by: Travis Oliphant | last post by:
Numarray is making great progress and is quite usable for many purposes. An idea that was championed by some is that the Numeric code base would...
5
by: bandw | last post by:
I am having a problem using Numeric-24.0b2 in conjunction with the NetCDF module from ScientificPython (version 2.4.9). This problem does not...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here:...
5
by: Michael Sperlle | last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems to need changes to the kernel before it can be installed, and I have no...
2
by: goetzie | last post by:
I am using Python 2.4.1 and Numeric 23.8 and running on Windows XP. I am passing a Numeric array of strings (objects) to a C Extension module...
0
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473...
1
by: Preben | last post by:
Hi, don't know if this is the correct group, but try anyway. I would like to use boostbindings from the boost sandbox together with my project...
0
by: vaibhavk | last post by:
Hi, I am trying to transform a XML file into another XML using XSL (XSLT1.0): Original XML: <pfe-traffic-statistics>...
3
by: dizzy | last post by:
Hi I wonder if this code is standard conformant and should work on all conformant implementations (for some type T): 1: void* mem = ::operator...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.