|
There must be something else that is causing this that is external to your header file. I just tried that and it compiled without error. Does the error message give you any line numbers?
|
|
|
|
|
I noticed that the issue only occurs when i use "_" as function name. When i set it to something else it will work.
My namespace was named the same as my class, is it possible that the compiler did not detect the ambiguity?
modified 30-Sep-14 4:06am.
|
|
|
|
|
Well for some reason (that cannot be seen from what you have provided), the function is being defined in more than one place. You need to go through all your code again to see where.
|
|
|
|
|
Off the top of my head, one thing that may cause this message would be if you #include the header in multiple locations and have no header guards (either pragma once directive or #ifndef/#define/#endif method).
|
|
|
|
|
I am getting a run time error with the code below. Trying to use a static iterator to reduce the number of calls to search a vector.
This is a method of a class that contains a vector of curves (so _vector is part of the class.)
It runs correctly the first few times called, but the first time the static iterator doesn't point to the correct curve and _vector should be searched, I get a runtime error "Incompatible Vector Iterators" calling the == operator.
I can't really tell what the error is. If it is a const versus non-const or it is creating copies of the vector somewhere.
Is there a better way to do this?
Thanks
Mark
bool findpt(pt_tag<_Ty>* s)
{
if (_vector.empty())
return false;
static vector< curve<_Ty> >::iterator i = _vector.end();
if (i == _vector.end()) <-- RUN TIME ERROR HERE
i = std::lower_bound( _vector.begin(), _vector.end(), s->_dtEffDate );
else {
if ((i._Ptr->getdate() != s->_dtEffDate))
i = std::lower_bound( _vector.begin(), _vector.end(), s->_dtEffDate );
}
if ((i == _vector.end()) || (s->_dtEffDate != (*i)._date))
return false;
cpoint<_Ty> c;
c.setdate( s->_dtFwdDate );
if (i._Ptr->interpolate( &c ) == true) {
s->_valid = true;
s->_value = c.getvalue();
return true;
}
return false;
}
|
|
|
|
|
are you modifying the vector between calls to this function?
if so, that might (will, probably) invalidate 'i'.
|
|
|
|
|
I am canning this routine as the vector may end up being modified.
Thx for the input.
|
|
|
|
|
I placed a formview on a dialog because formview handle scroll itself.
Problem is: When I create and resize foemview (using movewindow) bigger than dialog, scroll does not appear. But when I do the same thing from resource ( create big formview dialog on design time) , scrolls appears.
I need to resize the formview based on content to I need scroll at run time.
Please suggest, how can I do?
|
|
|
|
|
Hi all.
I develop an application that send UDP packet to the embedded board. Embedded Board cannot receive packet because packet protocol changed to ARP.
If I replace the Embedded Board with a PC and sniff network with WireShark, UDP packets are seen. what's the problem?
If I send UDP packet with PacketBuilder to the Embedded board, it can receive it.
I use MFC CSocket class to send UDP packet.
My Code is:
CSocket sockSrvr;
if ( sockSrvr.Create(1239,SOCK_DGRAM)==0)
{
MessageBox("Can't create socket");
return FALSE;
}
char data[100];
memset(data,1,sizeof(data));
if ( sockSrvr.SendTo(data,sizeof(data),1239,"10.14.83.11")<=0)
{
MessageBox("Error in Sending");
return FALSE;
}
sockSrvr.Close();
return TRUE;
I test windows API to send UDP packet but not differ with CSocket.
thanks for your help
|
|
|
|
|
If the board will not accept UDP packets then there is not much you can do. You need to read the device's documentation to find out how it works.
|
|
|
|
|
Thank for your reply.
Board can accept UDP packet. It can receive packet that generated with colasoft packet builder.
Thanks again.
|
|
|
|
|
Well that seems to be your answer.
|
|
|
|
|
I downloaded several SVD c++ code, but they all have same error.
by SVD theory, a matrix A(mxn) (m: rows, n: columns) can be decomposed as
A(mxn) = U(mxm) * S(mxn) * V'(nxn)
(U, S and V are matrices)
U and V must be orthogonal matrices:
U x U' = U' x U = E, V x V' = V' x V = E
(E is identity matrix)
Problem:
if m > n, those codes generate U' x U = E (correct), but U' x U != E (error).
they are all correct for V.
Because all of codes have the same error, I think U should be this way even it is not satisfy SVD theory.
Or all codes are wrong (sounds not reasonable.)
How do you think about? maybe I have to download more C++ source codes to test?
.
|
|
|
|
|
This is mathematics not C++, so you need to go through the code to find out where the calculation is wrong.
|
|
|
|
|
Quote: if m > n, those codes generate U' x U = E (correct), but U' x U != E (error).
Probably you meant
if m > n, those codes generate U' x U = E (correct), but U x U' != E (error).
Anyway, if U' x U = E then U' = U<sup>-1</sup> , therefore U x U' = E .
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
You are right, I should go back to school now.
thanks.
|
|
|
|
|
You are welcome.
Don't become discouraged, maybe rounding made things more complex in your case.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
I am getting back into “real coding” and as usual have academic question, I hope.
I am collecting raw data from 10 bits A/D - in uint16_t.
The FFT class I am using uses double to calculate stuff.
My silly question is – should I build overloaded function(s) using double type of variable or can I just cast the raw data as (double) function parameter?
Will casting do much damage to FFT processing?
Since I don't know how the processed data should look like, I need to make sure using casts is OK or not..
Thanks for your time and help
Cheers Vaclav
|
|
|
|
|
I am not sure what you mean by "do much damage to."
You can use a cast and pass the values as doubles but it will slow things down somewhat.
|
|
|
|
|
Thanks.
Speed penalty is immaterial since doing FFT is relatively "time consuming" already.
What I met was - will the FFT be reasonably accurate giving the (Arduino) processor hardware constrains. I guess I'll know after I reconstitute known signal.
Cheers Vaclav
|
|
|
|
|
You just need to convert the values by simple expressions of the form:
double doubleValue = integerValue;
Whether you do this before calling your function or within it is up to you.
|
|
|
|
|
So casting is a bad idea?
What exactly is the difference between cast and redefinition?
As a secondary question - the initial raw values are in an array in RAM.
I pass a pointer to this int array either by redefining it as double or as a cast.
I am not far enough it the coding , but I think the raw array is processed / modified.
How does it affect the original RAM size?
I assume it it still intact as int array, not a double.
Microprocessor has limited RAM and to process the signal using FFT the original raw data array needs to be as large as feasible ( right now I am testing the code using 64 "samples" ) - to fit it into RAM plus processed data by FFT.
Thanks for your help.
Cheers Vaclav
|
|
|
|
|
Vaclav_Sal wrote: So casting is a bad idea? Not at all, but you need to understand what you are doing when you use it. A cast is used to tell the compiler that you want to treat one object type as another, and that you understand the potential side effects.
Vaclav_Sal wrote: What exactly is the difference between cast and redefinition? Not sure I understand what you mean by "redefinition" in this context.
Vaclav_Sal wrote: I pass a pointer to this int array either by redefining it as double or as a cast. That does not make sense, you cannot use a cast to pretend that an array of integers is an array of doubles, they are totally different types.
|
|
|
|
|
Richard,
I read it as you have redefined int variable as double variable.
OK, this is getting into "what if" area.
I am going to build the raw data as double to start with and later on find a microprocessor with more RAM than this one so I do not have to limit the sample length.
Here is yet another question - because the original data is 10 bits and I do not want to carry any garbage in unused bits - how do I mask the 10 bits into double ( 32 bits) variable?
Which in these four 8 bits are the value and which are after the "decimal points" values?
Sorry , I just do not know the proper mathematical English terms.
Or maybe I just use "redefinition" from int to double on the result of the AD conversion, as you suggested, just KISS.
BTW as I suspected - the original raw data gets processed few times over to various FFT data. I need to analyze the original code to find out how did the raw data started as int array and was processed into double. IMHO that would messed up the memory big time - unless the int array dimension is doubled to make room for the half sized double array.
FFT results are "symetrical" , thus the "samples" are cut in half.
Fun.
Cheers Vaclav
|
|
|
|
|
No that was not a redefinition but a conversion.
int integerValue = 233;
double doubleValue = integerValue;
I am getting a bit confused as to your raw data and what format it takes. If it is in integer form and you need to convert it to double values then you need to use expressions like the above to convert it.
It's a long time since I did any serious maths, so forgive me if I struggle to understand your questions.
|
|
|
|