|
So, what else information do you want to know ?
Because I want to know, how to write code with fast access to array's elements.
I've got simple linear array of integers.
Matrix product is n^3 problem.
Can I handle array memory faster then array[i] ? Or some compiler switches for pointers ...
The aim of my programme is matrix inversion and part which is consumes the most of time, is matrix product.
... right now we have 3:00 pm, so good afternoon;
-- modified at 9:14 Sunday 9th October, 2005
|
|
|
|
|
Sorry! It was way passed my bed time, you did provide enough imformation.
The order in which the calculation are done matters:
(VC6.0, optimizations: maximum speed, Compiled for release)
#define MATRIX_SIZE 1000
int M1[MATRIX_SIZE];
int M2[MATRIX_SIZE];
int M3[MATRIX_SIZE];
void matrix_speed_test()
{
int j, i, k;
for( j=0;j<MATRIX_SIZE;++j )
for( i=0;i<MATRIX_SIZE;++i )
for( k=0;k<MATRIX_SIZE;++k )
M3[j] = M1[i] * M2[k];
}
void matrix_speed_test2()
{
int j, i, k;
int m1,m2;
for( j=0;j<MATRIX_SIZE;++j )
{
m1 = M1[j];
for( i=0;i<MATRIX_SIZE;++i )
{
m2 = M2[i];
for( k=0;k<MATRIX_SIZE;++k )
M3[k] = m1 * m2;
}
}
}
void matrix_speed_test3()
{
int j, i, k;
int m1;
for( j=0;j<MATRIX_SIZE;++j )
{
for( i=0;i<MATRIX_SIZE;++i )
{
m1 = M1[i];
for( k=0;k<MATRIX_SIZE;++k )
M3[j] = m1 * M2[k];
}
}
}
As you can see, rearanging the code to change where the indexing occurs can greatly increase the speed.
I tried a few other ways, but they still avaraged 2.17 seconds.
I hope that helps!
P.S. Sorry for the delay, I am usualy only online when reasearching.
INTP
Every thing is relative...
|
|
|
|
|
Does anyone here have any experience using the Free .Net C++ command line tools?
Is it possible to build programs that are built using the Multi-threaded DLL code generation options if you use STL? The site says that it only comes with static libs for trhe CRT and STL. Does this mean that /MD won't work?
I have a series of DLL's some of which depend on each other. All use the STL, and my understanding is that to allow them to work I *have* to build in /MD or /MDd (Multi-Threaded Debug) mode. Is this possible to do with the Free tools? If not, is there a work around?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
1st: Kudos on the "Dune" reference.
Jim Crafton wrote:
Is it possible to build programs that are built using the Multi-threaded DLL code generation options if you use STL?
Yes!
You have to understand that the STL does not care about multi-threading, it is irrelevant. The code that uses those template classes are the ones who have to care.
INTP
Every thing is relative...
|
|
|
|
|
OK, thanks!
However when I tried to build with it, I get link errors saying it can't find msvcrtd71.lib (or something like that).
I tried a simple test with the following:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
extern "C" {
__declspec(dllexport) void doit();
}
void doit()
{
int f = 90;
f += 345;
}
When I build this with /MDd (or /MD) I note that despite the fact that NO CRT code is used (as far as I can tell), it automatically links and uses the MS CRT DLL anyways!!!
My understanding is that you cannot use STL in DLL's that are NOT built with "Multi-threaded DLL" code generation options. So if you have DLL A and it uses STL (and has functions that use std::string) and have DLL B, that also uses DLL A, and both use std::string, then you must generate them using the "Multi-threaded DLL" code gen option.
What I remember is that if you just use the "Multi-threaded" option (i.e. static linkage to the CRT) then the strings will become corrupted.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Good day,
I have a parent dialog instatialing a modeless dialog. My modeless dialog has a public function that updates the progress bar. Everytime I call tmpmodeless->UpdateProgressBar(step) where step is a number to increase, the progress bar show increase on display. I have also a public function in modeless dialog that updates the text for displaying the status tmpmodeless->UpdateMessageStatus(CString mymsg) but I doesnt update the display..
Here is my code:
// Variables of modeless dialog
CProgressCtrl m_ctrlProgress; // Created using MFC Class wizard so it sure points to the
// control id of progress bar.
CStatic m_statusdone; // Created using MFC Class wizard so it sure points to the
// control id CStatic control id. Also sure that Visible property is checked.
CMyParentDialog::MyInitialize()
{
CMyModelessDialog* tmpmodeless=new CMyModelessDialog(this);
tmpmodeless->Create(CMyModelessDialog::IDD);
tmpmodeless->ShowWindow(SW_SHOW);
tmpmodeless->UpdateProgressBar(10); //OK is reflects on screen
tmpmodeless->UpdateMessageStatus("Help me step 10"); doesnt change display..
tmpmodeless->UpdateProgressBar(20); //OK is reflects on screen
tmpmodeless->UpdateMessageStatus("Help me step 20"); still doesnt change display..
}
void CMyModelessDialog::UpdateProgressBar(int pStep)
{
m_ctrlProgress.SetPos(pStep);
}
void CMyModelessDialog::UpdateMessageStatus(CString mymsg) //Doesnt work.. why???????????????
{
m_statusdone.SetWindowText(mymsg);
UpdateData(TRUE);
}
Still Doesnt appear even if I manually put m_statusdone.SetWindowText("Test") under UpdateProgressBar because UpdateProgressBar sure does works on setting progressbar.
Is there something Wrong with CStatic control????
Thanks.
|
|
|
|
|
fjlv2005 wrote:
void CMyModelessDialog::UpdateMessageStatus(CString mymsg) //Doesnt work.. why???????????????
{
m_statusdone.SetWindowText(mymsg);
UpdateData(TRUE);
}
Why are you calling UpdateData(TRUE) at that point? Was it just for testing purposes?
Make sure your static control uses an identifier different than IDC_STATIC (i.e, -1)
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Good day,
Yes Im sure im using ID which is not IDC_STATIC. UpdateData is just for testing...
Why does it doesnt update the display for my modesless dialog??
|
|
|
|
|
How in CEdit to install the cursor in anchor point?
C++ MFC
SetSel installs the cursor in an active end and scrolls the text, I should place(install) the cursor in anchor point, for auto replacement.
|
|
|
|
|
Could you go a little bit more ... in detail ?
SkyWalker
|
|
|
|
|
SetSel(...);
Just make the starting position and ending position the same (anchor point).
The carat (anchor) position is the starting position.
Note: You can reverse the positions passed to SetSel(...) by reversing the starting and ending points..
Under Windows the cursor position is the mouse arrow position and not the position of the text cursor (that's called a caret).
INTP
Every thing is relative...
|
|
|
|
|
Hello,
I have a CButton created dynamically with bitmap:
CButton
m_mybutton.Create(NULL,WS_CHILD|WS_VISIBLE|BS_OWNERDRAW,CRect(1,87,110,107),this, ID_BTNHEADBOOKMARK);
m_mybutton.LoadBitmaps(IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK, IDB_LISTHBOOKMARK);
The image have some area with Color RGB(255,0,255).
I wanted those area with that color above to be transparent.
How can I do it?
Hope i could get a response ASAP (if possible )
Also im using EVC, you can try it Visual Studio and if works, i'll try it to EVC3.0.
Thanks you very much.
|
|
|
|
|
My suggestion:
Derive a subclass from CButton, modify its style as owner-draw.
Overwrite the DrawItem() and use TransparentBlt() to paint the bitmap by yourself.
Lane
|
|
|
|
|
Lane,
I understand how to override DrawItem by creating a class derived from CButton, however there no TransparentBlt API in EVC3.0. Anyway to do TransparentBlt?
Thanks Lane
|
|
|
|
|
NewVCbie wrote:
Anyway to do TransparentBlt?
You can use the "True Mask" method. It is the method used by windows to draw icons. It involves creating a black and white mask bitmap that uses white as the transparent part and black as the opaque part. You can have a look at my article at http://www.codeproject.com/bitmap/pjaimage.asp[^] where I use the method to draw transparent bitmaps. Look at the CPJAImage::DrawTransparent() method.
Google[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
|
Hi!
I am working on MFC SDI application.
can anybody tell me any good example of using extern keyword. can extern be used for passing value of any string variable from one class to another. If it can be used, then how?
thanx
|
|
|
|
|
swaapu says:can extern be used for passing value of any string variable from one class to another?
No it is not possiable using extern.
extern is for different purpose.
if you want to declare later and but if you want to use before itself then use key word extern.
Nice talking to you.
|
|
|
|
|
Hello,
The extern keyword is used to say to the compiler that you are using a variable declared in another translation unit. See the following for example:
You have one translation unit where you define your variable
int g_nSomeInt = 0;
And another one where you want to use the variable
extern int g_nSomeInt;
void DoFoo()
{
g_nSomeInt++;
}
This is how extern can be used. It is adviced though too use accessor functions instead of the extern keyword.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
The extern keyword simply states that the variable or function is declared in a seperate translational unit. That is it is declared and defined in a seperate file from the one that depends on it.
Declaring a function prototype as external, only serves to inform the coder that it is declared and defined in another file.
Defining a variable as external, informs the complire that it is declared and defined golobaly in another file. The difference between a function protype and a global variable, is that a global variable must be declared external and a prototype is external by default.
I've workd with C code that required alot on global variables (dealing with hardware specific addresses). In that case a file was set off to the side to define all the hardware specific data (global variables), which needed to be declared as extern.
INTP
Every thing is relative...
|
|
|
|
|
Hi
Urgent plz. Help me in how to use ADO to store and retrieve image data from Oracle using VC++.
Thanks in Advance
|
|
|
|
|
|
Hi
How to use CByteArray to store images into PostgreSQL database from VC++.
Help me.
Thanks
|
|
|
|
|
Hello,
does anybody here know a good C++/C Implementation of the GNFS(General Number Field Sieve) or the SNFS (Special Number Field Sieve) Algorithm ?
With best regards,
Benedikt
|
|
|
|
|
Hi!!
I am working on an SDI MFC application. I have two dialog boxes. I want to pass some File name from one dialog box to another on clicking OK command button. The file name has to be displayed on the text box of second dialog, when the second dialog appears on the screen .
Can any body tell me , how to declare variables and wat functions to use. I am new to MFC.
Thanx
|
|
|
|