|
Your routine generates a standard normal distribution (0 mean and 1 std dev), that you can use to generate a distribution with any mean or std dist.
Just use this transform:
N = Z * sigma + mu
where Z is standard normal, sigma is the std. deviation and mu is the mean.
|
|
|
|
|
Hi all,
I need to use SQLite to write a C++ program on my Ubuntu Netbeans.
How do I setup my netbeans for me to be able to #include <sqlite3.h> ?
I have read the sqlite.org pages and googled but still have no idea as I am a Noob in C++ and Ubuntu.
can anyone provide a step by step tut?
your help is very much appreciated. Thanks!
|
|
|
|
|
Do you have the C++ plugin for NetBeans? If not then download and install it. Then just add your include statement in your source module as necessary.
If you want a tutorial then I am sure you will find one on the NetBeans website.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Yes i do have the C++ plugin. the thing I need is to setup SQLite which i do not know how.
|
|
|
|
|
xivShin wrote: I need is to setup SQLite which i do not know how.
I would suggest the SQLite[^] website is the best place for help.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Add the sqlite3.h and sqlite3.c to the project, and include "sqlite3.h" in the file you need to use SQLite. You can then use SQLite functions from there. I would suggest you use one of the C++ wrappers to simplify the programming on the SQLite part. Some of them are available from CodeProject. I found most of them directly usable, but need refinement.
|
|
|
|
|
This is an MFC forum. There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: This is an MFC forum.
Not exactly, it is C/C++/MFC, so his question is (sort of) acceptable.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
You may - install
sqlite3 . - include
sqlite3.h in your source file(s). - compile specifying
-lsqlite3 . If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Finally got it working ! thanks guys.
|
|
|
|
|
You are welcome. Have a nice ubuntu-sqlite experience (I'm using that pair too)!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I am getting unexpected results due to my lack of understanding of static const initialization. Basically, I thought the rule is that static const members are initialized in the order in which they are declared (just like member variables). However, I have some code that is yielding unexpected results, which I have copied below to illustrate the issue.
#pragma once
#ifndef COMMON_H
#define COMMON_H
typedef unsigned __int8 __uint8 ;
typedef unsigned __int16 __uint16;
typedef unsigned __int32 __uint32;
typedef unsigned __int64 __uint64;
template<size_t bytes> struct __float {
public:
static const __uint8 MantissaSize;
static const __uint8 SignificandSize;
static const __uint8 ExponentSize;
static const __uint16 ExponentMax;
static const __uint16 ExponentBias;
static const __int64 SignificandBit;
static const __int64 MantissaMask;
static const __int64 SignificandMask;
static const __int64 ExponentMask;
};
template<> const __uint8 __float< 2>::MantissaSize = 10;
template<> const __uint8 __float< 4>::MantissaSize = 23;
template<> const __uint8 __float< 8>::MantissaSize = 52;
template<size_t bytes>
const __uint8 __float<bytes>::SignificandSize = __float<bytes>::MantissaSize + 1;
template<size_t bytes>
const __uint8 __float<bytes>::ExponentSize = (bytes << 3) - __float<bytes>::SignificandSize;
template<size_t bytes>
const __uint16 __float<bytes>::ExponentMax = (1 << __float<bytes>::ExponentSize) - 1;
template<size_t bytes>
const __uint16 __float<bytes>::ExponentBias = __float<bytes>::ExponentMax >> 1;
template<size_t bytes>
const __int64 __float<bytes>::SignificandBit =
static_cast<__int64>(1) << __float<bytes>::MantissaSize;
template<size_t bytes>
const __int64 __float<bytes>::MantissaMask =
__float<bytes>::SignificandBit - 1;
template<size_t bytes>
const __int64 __float<bytes>::SignificandMask =
__float<bytes>::SignificandBit | __float<bytes>::MantissaMask;
template<size_t bytes>
const __int64 __float<bytes>::ExponentMask =
static_cast<__int64>(__float<bytes>::ExponentMax) <<
__float<bytes>::MantissaSize;
#endif And now, the main function:
#include <iostream>
#include "Common.h"
using namespace std;
double getOnePointFive() {
__uint64 rval(0);
rval = (static_cast<__uint64>(__float<8>::ExponentBias) << __float<8>::MantissaSize) |
(1ULL << (__float<8>::MantissaSize - 1));
return *reinterpret_cast<double*>(&rval);
}
int main(int argc, const char* argv[]) {
cout << getOnePointFive() << endl;
cout << __float<8>::ExponentBias << endl;
cin.get();
return 0;
} When this runs, I would expect to get the result 1.5, and the value of __float<8>::ExponentBias should be 0x3FF. However, I am getting zero for the ExponentBias value which results in the subnormal value 3*2^-1024. Why is the value of ExponentBias coming out as zero? Thanks,Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
|
Yes, I saw that post in my quest for a solution, but I can't figure out how to go about initializing the members based on template specialization. Any ideas?
Oh, I also get the compiler error C2057 when I move all of the non-specialized declarations within the structure definition. In other words, I attempted the following:
template<size_t bytes> struct __float {
public:
static const __uint8 MantissaSize;
static const __uint8 SignificandSize = MantissaSize + 1;
static const __uint8 ExponentSize = (bytes << 3) - SignificandSize;
static const __uint16 ExponentMax = (1 << ExponentSize) - 1;
static const __uint16 ExponentBias = ExponentMax >> 1;
static const __int64 SignificandBit = 1LL << MantissaSize;
static const __int64 MantissaMask = SignificandBit - 1;
static const __int64 SignificandMask = SignificandBit | MantissaMask;
static const __int64 ExponentMask = static_cast<__int64>(ExponentMax) << MantissaSize;
};
template<> const __uint8 __float< 2>::MantissaSize = 10;
template<> const __uint8 __float< 4>::MantissaSize = 23;
template<> const __uint8 __float< 8>::MantissaSize = 52; This resulted in a number of C2057 errors about expecting a constant expression. I must be misinterpreting your recommendation, because I can't figure out how to make such a thing compile. Thanks for any additional help,Sounds like somebody's got a case of the Mondays
-Jeff
modified on Tuesday, February 16, 2010 9:45 AM
|
|
|
|
|
OK... I found a pretty good thread here[^] that talks about initialization of static const template members. I still don't understand why the code I originally posted doesn't work, but I did see a statement in this post that clearly indicated that all compile-time constant initialized static const members are performed prior to all dynamically initialized static members. Therefore, I decided to remove the dependencies on all dynamically defined static const members, instead repeating the math based on MantissaSize which is ALWAYS (according to the referenced post) defined prior to the other members. Now when I run, I no longer get any errors, and instead get the intended result. I copied my new code below:
template<size_t bytes> struct __float {
public:
static const __uint8 MantissaSize;
static const __uint8 SignificandSize;
static const __uint8 ExponentSize;
static const __uint16 ExponentMax;
static const __uint16 ExponentBias;
static const __int64 SignificandBit;
static const __int64 MantissaMask;
static const __int64 SignificandMask;
static const __int64 ExponentMask;
};
template<> const __uint8 __float<2>::MantissaSize = 10;
template<> const __uint8 __float<4>::MantissaSize = 23;
template<> const __uint8 __float<8>::MantissaSize = 52;
template<size_t bytes>
const __uint8 __float<bytes>::SignificandSize = __float<bytes>::MantissaSize + 1;
template<size_t bytes>
const __uint8 __float<bytes>::ExponentSize =
(bytes << 3) - __float<bytes>::MantissaSize - 1;
template<size_t bytes>
const __uint16 __float<bytes>::ExponentMax =
(1 << ((bytes << 3) - __float<bytes>::MantissaSize - 1)) - 1;
template<size_t bytes>
const __uint16 __float<bytes>::ExponentBias =
(1 << ((bytes << 3) - __float<bytes>::MantissaSize - 2)) - 1;
template<size_t bytes>
const __int64 __float<bytes>::SignificandBit =
1LL << __float<bytes>::MantissaSize;
template<size_t bytes>
const __int64 __float<bytes>::MantissaMask =
(1LL << __float<bytes>::MantissaSize) - 1;
template<size_t bytes>
const __int64 __float<bytes>::SignificandMask =
(1LL << (__float<bytes>::MantissaSize + 1)) - 1;
template<size_t bytes>
const __int64 __float<bytes>::ExponentMask =
((1LL << ((bytes << 3) - __float<bytes>::MantissaSize - 1)) - 1)
<< __float<bytes>::MantissaSize; Again, if anyone can explain why my initial code didn't work I would really appreciate it. Thanks,Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi,
How to drag image list from one window to another window in MFC MDI application.
Thanks & Regards,
Ratheesh.
|
|
|
|
|
Hi All,
I am using one com dll and have multiple clients on the same machine which are creating pointers for same interface, so is there can be any conflict.
Example:
SomeComComponentLib::IsomeInterface objInterfaceptr;
.....create instance
Now all the client applications are using objInterfaceptr in same way...Please provide me some suggestion to avoid conflict.Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
What conflict?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Actually i want to ask that can it cause any coflict...
in my situation:
Some times i am not able to use the method of the interface object.
like application doesnt acknowledge the object and returns without performing the task.Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Ash_VCPP wrote: Actually i want to ask that can it cause any coflict...
I suppose not (but, without code, is a blind guess).
Ash_VCPP wrote: Some times i am not able to use the method of the interface object.
like application doesnt acknowledge the object and returns without performing the task.
What do you mean with: "application doesn't acknowledge the object?". Do you get errors?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ok let me explain you the problem in detail...
i am using msscript.ocx to get script support, now i am using one com dll and using its interface and adding interface object in script object, now script is using these object without initializing it, now i have same application running multiple times on same machine repeating the process, but some times vbscript doesnt acknoledge the interface objects.
Example:
m_ScriptObj.AddObject("DataIn", DataIn, false);
m_ScriptObj.AddObject("DataOut", DataOut, false);
m_ScriptObj.AddObject("Parser", Parser, false);
m_ScriptObj.AddObject("Setting", Setting, false);
now suppose i am using DataIn object inside my vbscript, and here comes the Inconsistent behaviour.Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|
|
Unfortunately it looks like there is no documentation about the script control (or I am not able to find it...). I have used it in the past, but I never needed the AddObject method.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
I want to write a code in which i want to change the icon of an exe i.e user will provide a icon at runtime and when he will click on change button the icon should be the new one....
How can i do this...
Thanks in advance
|
|
|
|
|
Try with UpdateResource[^]. Please note that using this will not actually update the already loaded resources in memory (meaning using UpdateResource to change the icon inside the exe will not magically change the icon you see in the top-left corner of the application's window for example to the new one, you will have to do that yourself, maybe by broadcasting some message to your windows to re-load the icon or such), however if you then quit and re-start the program the new icon should appear (also the new icon should be displayed in explorer and so...you might also need to do something to make explorer notice the change, am not sure about that...). > The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
I dont know how to do this but ToDoList[^] does that during Time Tracking. Maybe you can look at its source and figure it out.
-Saurabh
|
|
|
|