473,385 Members | 1,901 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 1821
"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 stay static and be replaced entirely by Numarray. ...
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 surface using Numeric-23.8. The problem arises in...
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: http://www.keymedia.biz/demo.htm Can anyone...
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 intention of going through whatever hell that would...
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 using the following python code: import Numeric...
0
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473 0.01951756438393204
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 where I use boost::numeric::ublas vectors and...
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> <pfe-input-packets>5678</pfe-input-packets>...
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 new(sizeof(T)); 2: T* p = new(mem) T(args...);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.