|
are you getting an error message of any kind ?
|
|
|
|
|
Claims there are no operators available, to support the abstract vector algebra.
Error 2 error C2679: binary '-' : no operator found which takes a right-hand operand of type 'aa::vector<base>' (or there is no acceptable conversion) matrix.h 114 1 fibonacci
http://www.contract-developer.tk
|
|
|
|
|
vector operator-(const vector *that) { // parallelogram law
vector ret;
assert(this->data.size() == that.data.size());
ret.resize(this->data.size());
#pragma omp parallel for
for (int i = 0; i < this->data.size(); i++)
ret.data[i] = this->data[i] - that.data[i];
return ret;
};
http://www.contract-developer.tk
|
|
|
|
|
Without knowing what your representation of matrix is it's a bit hard to work out if you're copying it correctly.
Cheers,
Ash
PS: Having said that what you've implemented is going to be more of a factory or clone method. While it might be legal C++ it wouldn't half surprise anyone trying to use the class. Would you expect that writing a = b; wouldn't change the value of a?
|
|
|
|
|
Should be:
matrix operator=(const matrix &that) {
for (int i = 0; i < this->rows; i++)
for (int j=0; j < this->cols; j++)
(*this)[i][j] = that[i][j];
return *this;
}
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 trying to load a picture from memory
from inspection can you see why this dosen't work?
here is part of the class I am using:
BOOL CPicture::Load(IStream* pstm)
{
Free();
HRESULT hr = OleLoadPicture(pstm, 0, FALSE,
IID_IPicture, (void**)&m_spIPicture);
return hr == S_OK;
}
here is some code I have found to implement this:
ifstream file ("c:\\1.jpg", ios::in|ios::binary|ios::ate);
if (file.is_open())
{
size = file.tellg();
memblock = new char [size];
file.seekg (0, ios::beg);
file.read (memblock, size);
file.close();
IStream *pStrm = NULL;
HGLOBAL hgbl = GlobalAlloc (0, 852);
CreateStreamOnHGlobal (hgbl, true, &pStrm);
pStrm->Write(memblock, size, 0);
delete [] memblock;
m_pict.Load(pStrm);
}
Thabk you your help will be much appreciated Simon
|
|
|
|
|
simon alec smith wrote: from inspection can you see why this dosen't work?
Not really, unless you explain what you mean by "doesn't work"; such a statement does not help in understanding what your problem is. Does your program crash, throw an exception, paint the image upside down, etc.?
It's time for a new signature.
|
|
|
|
|
This is what was reported,
File c:\program files\microsoft visual studio\vc98\atl\include\atlbase.h
line 622
expression: p!= 0
|
|
|
|
|
simon alec smith wrote: expression: p!= 0
And how does this relate to your code, where does the stack history point to in your program?
It's time for a new signature.
|
|
|
|
|
This does not work as expected, for matrix * matrix
matrix operator*(const matrix that) { // matrix product AB != BA
matrix ret;
ret.resize(this->data.size(), that.data.size());
for (int i = 0; i < this->data.size(); i++) {
for (int j = 0; j < this.data[i].size(); j++) {
for (int k = 0; k < this->data.size(); k++) {
#pragma omp parallel for
for (int l = 0; l < this.data[i].size(); l++) {
ret[i][k] += this->data[i][k] * that.data[j][k];
}
}
}
}
return ret;
http://www.contract-developer.tk
|
|
|
|
|
So what exactly is the question? Have you used the debugger to step through the code? Have you removed the #pragma directive? Have you worked out on paper how to do the multiplication?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
The result from a test != book
http://www.contract-developer.tk
|
|
|
|
|
VeganFanatic wrote: for (int i = 0; i < this->data.size(); i++) {
for (int j = 0; j < this.data[i].size(); j++) {
for (int k = 0; k < this->data.size(); k++) {
#pragma omp parallel for
for (int l = 0; l < this.data[i].size(); l++) {
ret[i][k] += this->data[i][k] * that.data[j][k];
}
}
}
}
AFAIK it should be
for (int i = 0; i < this->rows; i++)
for (int j = 0; j < that->cols; j++)
{
ret[i][j] = .0;
for (int k = 0; k < this->cols; k++)
ret[i][j] += this->data[i][k] * that.data[k][j];
}
Why do you need the further loop?
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 need to parse a .dat file which contains hexadecimal data. I need to parse the contents and store it as a text file.
I have the .dat file and the header file. Can anyone tell me how should I start with it or what are the steps involved.
|
|
|
|
|
Depends on what the hex represents... is it ASCII? is it archived? Is there a certain algorithm encoding it?
Josh Davis
Always looking for blackjack. Or maybe White Frank. One of the two.
|
|
|
|
|
the pseudo-code would be:
1. open the input file
2. create the output file
3. for each line in input file: read it, process it, write results to output file
4. close output file
5. close input file
6. terminate
However your description sucks a little, there is no such thing as hexadecimal data: all files contain either text or they don't; and every byte can be displayed as ASCII, Unicode, or be formatted in binary, octal, decimal, hexadecimal.
So maybe what you mean is: I have a text file containing a hexadecimal representation of some data, but then what would be the conversion you need, as it already is text?
So try to clarify; and to confirm your description, add a little example (input line, matching output line).
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
The .dat file contains few information as
path of a file,filename,date of creation of file etc. These information are stored as hex in the .dat file.
Depending upon the header file I need to extract these data and store it in a text file as normal text.
|
|
|
|
|
To further expand on Luc's answer from point 3 of "process it", you can use strtok_s[^] to extract hex characters from each line.
|
|
|
|
|
I have a skinned dialog that I am attempting to place transparent buttons on; based on CButton. However, when I do a create I find that a blank space is created where my button should be. Therefore the background that shows through my transparent image is white rather than the skinned bitmap that should appear. I imagine that the reason this area is not painted is because that area is to be painted by the button.
Is there a way to get that area of the background painted despite the fact that the button is to be painted there?
Thanks in advance.
|
|
|
|
|
(I assume that the buttons you are creating are subclassed CButton .) The white spaces is created by someone somewhere. Did you check your handling of WM_ERASEBKGND ?
|
|
|
|
|
wm_erase_backgroud should return TRUE;
and show your background images in ONpaint method.
|
|
|
|
|
I do handle OnPaint, it was a silly misstatement. I am not sure what you mean by "show your background images in OnPaint method"
|
|
|
|
|
Make sure you don't have WS_CLIPCHILDREN specified for your dialog window.
|
|
|
|
|
I apologize if my attempt to be succinct ended up being unclear. I have looked into what each of you have asked.
@Mattias G:
Yes, it is a subclassed CButton. I definitely agree that this is being created somewhere, it is just the where I am having difficulty with. I've looked at the OnEraseBkgnd and haven't found anything out of the norm.
@shivanandgupta:
My OnEraseBkgnd does return true. I do not handle Onpaint method in my dialog.
@Niklas Lindquist
I do not have WS_CLIPCHILDREN specified in my dialog window.
I feel like this is actually rooted in how Create is handled by CButton, one of the window or button styles. I will write back if I find anything.
|
|
|
|
|
Dear what do you want pls tell me details
If you want customize button with some bitmap .
and your dialog has background Bitmap.
firstly you draw dialog bitmap in onpaint dialog.
and derived class button should also call own onpaint method with button bitmap.
|
|
|
|