|
Dear all,
I am new for this site as well as for VC++. I recently got a job
I am working on data compression/decompression. Be very much clear Not file compression/decompression.I am to compress the data cluster by cluster of any harddisk. how can i compress a cluster into bytes or sector? I have no clue about it
All suggestion are welcomeed .
Thanks
snav
|
|
|
|
|
this is a crap idea! if you compress a cluster then the cluster is not full anymore. if you move other data in there then, then you need much time to decompress the whole thing again... in my opinion a silly idea, not worth the work on it. by the way, coding this is quite complicated, too, because it has to run as a storage filter driver.
Don't try it, just do it!
|
|
|
|
|
Hi
Alexender
Thanks for the suggestion and replay.
I agree with u but what i just want to do. I read a cluster using ReadFile() function and keep it in buffer . Now my question is how to compress this data which is in buffer so that if i write it any other place as a backup. It takes less memory space in HDD or any other storing device.
I am to compress files but cluster by cluster because i want to store the backup of this file in bytes(row) form not in file form [compressed file takes clusters again wastage of space ] .
This might be crap idea. But u would be able to help me , i'll be thankfull.
Now Ball is in your goal
|
|
|
|
|
I've got HUGE problems with floating point precision lost
in the following code:
- s*(a.y-c.y) - h*(b.y-c.y)
where
s = h = 0.333....
c.y = 0.675
a.y = b.y = 0
The result is about 5.e-17 (as I understand, NAN).
How to overcome the problem, forex
find out that precision lost occured.
Thank you for help, A. M.
gp123456
|
|
|
|
|
try a.y = b.y = 0.0;
TOXCCT >>> GEII power
|
|
|
|
|
toxcct wrote:
try a.y = b.y = 0.0;
Of cource, a.y & b.y are doubles too!
So read a.y = 0.0, b.y = 0.0
Suppose you haven't understood my question:
precision lost is a result of existing in my
program double values with infinite part after
floating point, e.g. that
s = 0.3333... (infinite 3's after floating point)
&
h = 0.3333... (infinite 3's after floating point).
|
|
|
|
|
could you give a piece of code (the equation calculation for example) ?
TOXCCT >>> GEII power
|
|
|
|
|
Loss of precision is an inherent problem with floating-point numbers (float and double ). You should never test for equality between two float s/double s because of this, but instead test that the difference is less than some threshhold.
To get around this, you'll need to use some alternate means of manipulating floating-point numbers.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"Just because the box has 2 gigabytes of memory doesn't mean you get to use it all!"
-- Rico Mariani, CLR perf guy
|
|
|
|
|
Michael Dunn wrote:
you'll need to use some alternate means of manipulating floating-point numbers.
You right! But I'd like to know which one exactly. Some useful links are welcomed.
|
|
|
|
|
It would be wise to compare the result from above formula with result from
-s*ay - h*by + cy*(s+h)
and if results dont compare have some kind of error recovery. if calculations are not too many and time bound most wise programmers(not me) calculate with 2 formulae and compare results.
|
|
|
|
|
Mike is correct. However, there is something more going on.
Are you sure that "s == h"? Even with floating point imprecision, I don't see how the two parts of the expression won't cancel each other out. I tried this with initializing h and s to 1.0/3.0 and it worked properly.
However, generally speaking, checking for "== 0" with floating point numbers is a VERY bad idea. Usually you need to check if "- epsilon < x < epsilon" where epsilon is your tolerance for imprecision.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
You know, I'm not checking if h==s, I just execute the code.
I found out that h==s using debugger.
I'm interested in way to find out that precision lost occured in
MS VisualC++ 7.0.
|
|
|
|
|
Follow the link below, you will know why there is loss in precision:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_why_floating_point_numbers_may_lose_precision.asp
To solve the problem, there is a free library called MAPM which can help you to calculate precisly:
http://www.tc.umn.edu/~ringx004/mapm-main.html
Hope that it can help.
|
|
|
|
|
The problem solved itself!
I've changed computer (from Celeron 800 MHz to Celeron 2GHz),
and the equation doesn't affects the results!
Anybody knows the reason?
I heard something about bugs in FPU of P300-1000...
Anyway, thank you very much for links, Hing.
They are very useful for me.
|
|
|
|
|
Hi!
I'm looking for a special algorithm, either a one ready-to-use or at least a description of how to begin:
Say I have a image file (.jpg), I want to analyze what color/s has/have the biggest potion - say I have an image with many gray tones, then I want to get the RGB value of this gray color, or an average of the most used gray tones in the picture.
I hope my question was clear enough
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
The easiest way is to build a histogram - count how many appearances each color has.
|
|
|
|
|
why dont you add the r, g and b values of every pixel and compare the sum?
Don't try it, just do it!
|
|
|
|
|
There are some small programs of examining bitmaps at www.flounder.com, you'll need to convert them to .bmp first.
If nothing else, they may give you a good start.
Good luck!
INTP
|
|
|
|
|
Thanks, I will try some of your suggestions
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hallo!
I'm a beginner with MFC... can somebody tell me how can I read 3 parameters from a *.txt into a Class.
//actually it would be 3 points of an triangle and I would load the co-ordinates of Points from the file
<br />
typedef int Point[2];<br />
<br />
class Point : public CObject<br />
{<br />
public:<br />
<br />
<br />
Points(){};<br />
<br />
Pont SummPoints[5];<br />
int PointNumm;<br />
bool TriangleTest (Pont a, Pont b, Pont c) <br />
{<br />
double long1 = sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1]));<br />
double long2 = sqrt((a[0]-c[0])*(a[0]-c[0]) + (a[1]-c[1])*(a[1]-c[1]));<br />
double long3 = sqrt((c[0]-b[0])*(c[0]-b[0]) + (c[1]-b[1])*(c[1]-b[1]));<br />
if (long1>= (long2+long3)) return false;<br />
<br />
}<br />
};
Muad-Dib
mailto:adamo_piar@freemail.hu
Made in Hungary
|
|
|
|
|
do this :
<font style="color:blue;">int</font> i1, i2, i3;
ifstream my_file("c:\\folder\\my_file.txt");
my_file >> i1 >> i2 >> i3;
my_file.close();
according that your file look something like 125 21 31
TOXCCT >>> GEII power
|
|
|
|
|
Hello all,
Yet again another CPropertyPage question
I have these two propertypages which aren't identical but, however, contain some identical controls (that said, same message handlers and code).
So, instead of doubling my code by writing the same code in each CPropertyPage class I thought of two possibilities on how to only need to code it in one place (and hence making it easier to manage both pages):
1. Make an ordinary baseclass which both property pages derive from. Then each property page class has implemented the message handlers and simply call the base class' implementation.
2. Make a baseclass derived from CPropertyPage and implement message handlers for the shared controls. What I'm unsure about here, is if each property page knows how to correctly call the base class message handlers (is that even possible?).
Looking forward to some suggestions
|
|
|
|
|
Halloko wrote:
What I'm unsure about here, is if each property page knows how to correctly call the base class message handlers (is that even possible?).
the right base class will be called, you can put the common code in the base class derived from the CPropertyPage.
The common code should be generic and should not depend on specific propertypage control.
You need to handle the event in the derived class only and call the baseclass method that you have implemented to do the job that you want to do.
I dont know how much this would be applicable to you, but then i tried.
Regards,
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|
|
Mr.Prakash wrote:
You need to handle the event in the derived class only and call the baseclass method that you have implemented to do the job that you want to do.
So, what you're saying here is that I should have a base class which implements the different events but NOT the message handlers since each derived class should include those and then call the appropriate base class?
I was hoping it would suffice just to declare the message handlers in the base class and the framework would automatically route events to the base class without any work in the derived classes.
Did I understand you correctly?
|
|
|
|
|
Halloko wrote:
I was hoping it would suffice just to declare the message handlers in the base class and the framework would automatically route events to the base class without any work in the derived classes.
Technically,what you are trying to do, should work. But you might have one problem... Data Access.
Methods in the baseclass cannot access member variable in the derived class,
Plus for the events to work for the controls in both derived property page,they should have same IDC_XXX value.
I'll write a suicide note on a hundred dollar bill - Dire Straits
|
|
|
|