473,322 Members | 1,431 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,322 software developers and data experts.

compile error " instantiated from here"

Hi,
I have the following compile error instantiated from here, I appreciate
if someone can help me find out why?
g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp
.../stddev.cpp: In member function 'int
StatUtils::std_dev(std::vector<int, std::allocator<int> >&, int,
int)':
.../stddev.cpp:206: warning: converting to 'int' from 'double'
.../stddev.cpp:215: warning: converting to 'int' from 'double'
.../stddev.cpp:218: warning: converting to 'int' from 'double'
.../stddev.cpp: In member function 'int
StatUtils::mean(std::vector<int, std::allocator<int> >&, int, int)':
.../stddev.cpp:232: warning: converting to 'int' from 'double'
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/bits/stl_numeric.h:
In function '_Tp std::accumulate(_InputIterator, _InputIterator, _Tp,
_BinaryOperation) [with _InputIterator =
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
, _Tp = double, _BinaryOperation = do_std_dev<int>]':

.../stddev.cpp:215: instantiated from here
Here is the code :
template< class T1> class do_std_dev : public binary_function<T1, T1,
T1>
{
public:
do_std_dev(T1 mean): _mean(mean) { }

T1 operator() (T1 initial, T1 element) {
T1 x = element - _mean;
initial = initial + (x * x);
return initial;
}
private:
T1 _mean;
};

int StatUtils::std_dev( vector<int>& v, int start, int end)
{
int stdDev = 0.0;
int mean2 = mean(v, start, end);
vector<int>::iterator startIter = v.begin();
vector<int>::iterator endIter = v.begin();

startIter += start;
endIter += end;

// this is line 215 of stddev.cpp:
int stdDevSum = accumulate (startIter, endIter, 0.0,
do_std_dev<int>(mean2));

return stdDevSum;
}

Feb 13 '06 #1
2 8930
> [...]
../stddev.cpp:215: warning: converting to 'int' from 'double'
[...]


I recommend you provide a complete minimal example without any
conversion-from-int-to-double-issue. Focus e.g. on int first. As far
as I see the conversion is of no relevance for the
standard-deviation-feature you want to have. Maybe clearing the
conversion-issue already leads to a working program.

Feb 13 '06 #2
In article <11**********************@g14g2000cwa.googlegroups .com>,
ke*********@gmail.com wrote:
Hi,
I have the following compile error instantiated from here, I appreciate
if someone can help me find out why?
g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp
../stddev.cpp: In member function 'int
StatUtils::std_dev(std::vector<int, std::allocator<int> >&, int,
int)':
../stddev.cpp:206: warning: converting to 'int' from 'double'
../stddev.cpp:215: warning: converting to 'int' from 'double'
../stddev.cpp:218: warning: converting to 'int' from 'double'
../stddev.cpp: In member function 'int
StatUtils::mean(std::vector<int, std::allocator<int> >&, int, int)':
../stddev.cpp:232: warning: converting to 'int' from 'double'
/usr/lib/gcc/i386-redhat-linux/4.0.1/../../../../include/c++/4.0.1/bits/stl_nu
meric.h:
In function '_Tp std::accumulate(_InputIterator, _InputIterator, _Tp,
_BinaryOperation) [with _InputIterator =
__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int>
, _Tp = double, _BinaryOperation = do_std_dev<int>]':

../stddev.cpp:215: instantiated from here
Here is the code :
template< class T1> class do_std_dev : public binary_function<T1, T1,
T1>
{
public:
do_std_dev(T1 mean): _mean(mean) { }

T1 operator() (T1 initial, T1 element) {
T1 x = element - _mean;
initial = initial + (x * x);
return initial;
}
private:
T1 _mean;
};

int StatUtils::std_dev( vector<int>& v, int start, int end)
{
int stdDev = 0.0;
int mean2 = mean(v, start, end);
vector<int>::iterator startIter = v.begin();
vector<int>::iterator endIter = v.begin();

startIter += start;
endIter += end;

// this is line 215 of stddev.cpp:
int stdDevSum = accumulate (startIter, endIter, 0.0,
do_std_dev<int>(mean2));

return stdDevSum;
}


Look at the template for accumulate and remember that "0.0" is a double
whereas "0" is an int. What type does accumulate return?

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 13 '06 #3

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

Similar topics

2
by: Alexander Bartzas | last post by:
I'm trying to compile route.cpp part of the NetBench Suite (UCLA) and...: > g++ packet.cpp radix.cpp route.cpp -o route There is no problem in the compilation of the code but when I try to run...
2
by: Happy Li | last post by:
Need help! I have a project with one crystal report. How can I compile it with csc.exe. I have tried the following command line .it compile successfully..but when I run, it display error 'Unable...
5
by: TJS | last post by:
trying to display pdf file in browser fails on this line: Response.ContentType = "application/pdf" getting an error about no declaration found for "response" what declaration is needed ???
3
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I...
4
by: Bill Coan | last post by:
NOTE: This was posted earlier to vsnet.vstools.office under a different subject line but received no response. I'm having a problem automating Word's Find object from a .NET application, using...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
1
by: ken.carlino | last post by:
Hi, I have the following compile error instantiated from here, I appreciate if someone can help me find out why? g++ -O0 -g3 -Wall -c -fmessage-length=0 -ostddev.o ../stddev.cpp...
3
by: tony | last post by:
Hello! When I build an exe file that use 6 class library dll I get this error. Could not copy temporary files to the output directory. The file 'MeltPracStorage.dll' cannot be copied to the run...
6
by: JHNielson | last post by:
This is a very simple question.... I have a form that looks up Records for an unbound drop-down list. It has worked just fine up until last night. Now the button on the form to delete a record...
0
by: yyuan168a | last post by:
I'm upgrading a VS2003 project to VS2005 but got bunch of C2039 errors in xutility.h file during compiling: :\Program Files\Microsoft Visual Studio 8\VC\include\xutility(610) : error C2039:...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.