|
Ok, resize issue has been solved.
Secondly, as long m_arrBitmapData is private memeber, I want to return this memeber through a public method, I mean from this class ...
Something like that:
public:
CArray< CArray<COLORREF, COLORREF&>, CArray<COLORREF, COLORREF&> > GetBitmapArray(){return m_arrBitmapData;}
because this trial give me:
error C2558: class 'CArray<class CArray<unsigned long,unsigned long &>,class CArray<unsigned long,unsigned long &> >' : no copy constructor available
|
|
|
|
|
Just return a constant reference as in
const CArray< CArray<COLORREF, COLORREF&>, CArray<COLORREF, COLORREF&> > & GetBitmapArray()
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
I think is working ... I have one more question: there is a way to pass a paramanter as CArray< CArray<COLORREF, COLORREF&>, CArray<COLORREF, COLORREF&> >, just like:
void SetPlotData(CArray< CArray<COLORREF, COLORREF&>, CArray<COLORREF, COLORREF&> > InputArray);
and
void CGraphCtrl::SetPlotData(CArray< CArray<COLORREF, COLORREF&>, CArray<COLORREF, COLORREF&> > InputArray)
{
if ((m_PixelNumberX>0) && (m_PixelNumberY > 0))
{
PlotData = InputArray;
}
}
because code above doesn't work:
error C2582: 'CArray<class CArray<unsigned long,unsigned long &>,class CArray<unsigned long,unsigned long &> >' : 'operator =' function is unavailable
As soon as I solve this error, my program will run ...
modified 5-Sep-14 4:55am.
|
|
|
|
|
Quote: Now, I want to replace vector > with this CArray: That's not advisable. I wouldn't do it. As matter of fact the vector container is much better than the CArray one.
Quote: how can replace vector.resize method, Use the Carray::SetSize[^] method.
Quote: how can I return CArray< CArray<colorref, colorref&="">, CArray<colorref, colorref&=""> > data type The same way you return other data, e.g.
return m_arrBitmapData;
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
I would neither store nor return the bitmap data in that way. What you are creating here is a so-called "ragged" array, in which each row can have a different length. In a bitmap this luxury is not needed, all rows are of equal length by definition. Therefore a one-dimensional array is good enough and in some regards even superior.
a) A one-dimensional array can be allocated in one chunk (whereas your ragged array needs N allocations, N being the number of rows)
b) A one-dimensional array does not incur the overhead that comes with a ragged array, which is easily 3 x 64bits per row.
To access the members of the one-dimensional array in a 2D fashion, simply use the algorithm:
index of pixel (x, y) = x + y*pixelsPerRow
As a return value for your access function I would suggest you use a simple pointer (const COLORREF*).
For the caller to know how to access that 1D array you should provide addition access functions for the number or rows and number of columns.
|
|
|
|
|
Ohh, I would love to get rif of 2D array ... I had taken the class from here[^], could you assit me how to give up vector<vector<colorref>> BitmapData ? If I am not asking too much ... I will start working, to see what is happen ... See you.
|
|
|
|
|
It is not very difficult to get rid of this 2D array.
1) replace it with a vector<colorref> m_bitmapData;
2) Replace any reference to the old BitmapData array as follows:
BitmapData[x][y] should be replaced by m_bitmapData[x + m_PixelNumberX*y]
3) In SetBitmapDataSize allocate the new array by
m_bitmapData.resize (x * y);
Change the function interfaces accordingly. Should be really easy.
|
|
|
|
|
Kindly thank you NV3 ! I will let you know what I have done.
|
|
|
|
|
Great ! Is working, just like the original one ... I didn't replace 2D array by vector, but with CArray ... and is working ! Kindly thank you, NV3 !
|
|
|
|
|
|
Let two exes use same dll in windows platform at particular time.Then what is shared internally?Please correct me if I am wrong.
-Dll file in Hard disk is shared(Single copy).
-Instructions in Dll are loaded once and code can be used by both the executable.
-The objects in the Dlls are also shared by both executable.
Please clear me - The mechanism in windows os. whether this is same across all OS.
Thank you in Advance.
|
|
|
|
|
From MSDN[^]:
DLLs also help reduce memory overhead when several applications use the same functionality at the same time, because although each application receives its own copy of the DLL data, the applications share the DLL code.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
@CPAllinii
Thank you for answer. But if two dlls(having same signature) in two different directories and linked by tw different executable. Then what will happened? Is the design same across different OS.
Please answer.
|
|
|
|
|
|
There's an order by which exe's look for libraries. It will use the first one it finds, I believe CPallini gave you a link that specifies the search order. You can use tools such as Dependency Walker[^] to see what dll specifically is getting loaded by an exe if you're not sure which one it's loading. It is customary that shared dll's are placed in a location where any program that wants to use it has access to it, of course, this will require admin privilidges for your installer (assuming you place the dll copy in a system folder).
|
|
|
|
|
As far as object data (memory), that's not shared at all.... it's just the code that is shared. For example, if you have two exe's using an IO dll, the state of one will not affect the other, they're still independent while running. If you want them to share something, you have to set that up using other means (IPC).
|
|
|
|
|
HI,
I have Visual studio 2005 on WIn7 system. Project dependencies and Buildorder everything is in place and correct.
But it is not Building according to build order correctly when doing clean and Rebuild.
I checked with other win7 sytem it is doing properly there.
Any thoughts.
|
|
|
|
|
It could be because parallel compilation is used on a multi core machine. If two projects are not strictly dependent, they can be built in parallel.
If you wanted to enforce the build order (including single thread compilation), you could set the dependencies in a single row even though theprojects don't really depend on each other. But why would you want to do this?
The good thing about pessimism is, that you are always either right or pleasently surprised.
|
|
|
|
|
If build order is important, then specify project dependencies. That should make the build order exactly the same every time.
If memory serves right, in a multi-project solution, you can right click on a project and set dependencies within the menus there. When you make one project dependent on the others, Studio will build the dependencies first.
|
|
|
|
|
float determinant(float **input,int order)
{
int j,p,q,t,i;
float pr;
float d;
float *c;
float **answer;
answer=memory_alloc_2D1(order,order);
float **b;
b=memory_alloc_2D1(order,order);
for(j=1;j<=order;j++)
{
int r=1,s=1;
for(p=1;p<=order;p++)
{
for(q=1;q<=order;q++)
{
if(p!=1&&q!=j)
{
answer[r][s]=input[p][q];
s++;
if(s>order-1)
{
r++;
s=1;
}
}
}
}
for(t=1,pr=1;t<=(1+j);t++)
pr=(-1)*pr;
c[j]=pr*determinant(b,order-1);
}
for(j=1,d=0.0;j<=order;j++)
{
d=d+(input[1][j]*c[j]);
}
return(d);
}
main.c
float determinantmatrix;
determinantmatrix=determinant(covariance1,waveframesize);
//covariance1 is the input matrix
|
|
|
|
|
I'll guess that you are attempting to access past the end of an array.
code like this,
for(j=1;j<=order;j++)
would normally look like this.
for(j=0;j<order;j++)
as array access is zero based, from 0 to (size - 1)
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
it compile finely but while running segmentation fault occur and couldnt printf the output.
|
|
|
|
|
That issue (indexing past the end of an array) isn't a syntactic issue and won't be flagged by the compiler, it is a logic issue and you will only see a problem at run time.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|
|
but i cant find out where the logic is getting wrong can u help me out.
|
|
|
|
|
Do you understand what I said about array access?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
|
|
|
|