Click here to Skip to main content
16,007,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: about CListCtrl Pin
ika27-Feb-05 12:37
ika27-Feb-05 12:37 
GeneralElegant insertion of CBitmap into CRichEditCtrl Pin
Bartosz Bien6-Feb-05 12:44
Bartosz Bien6-Feb-05 12:44 
GeneralRe: Elegant insertion of CBitmap into CRichEditCtrl Pin
Sheng Jiang 蒋晟6-Feb-05 13:56
Sheng Jiang 蒋晟6-Feb-05 13:56 
GeneralRe: Elegant insertion of CBitmap into CRichEditCtrl Pin
Bartosz Bien6-Feb-05 14:02
Bartosz Bien6-Feb-05 14:02 
GeneralRe: Elegant insertion of CBitmap into CRichEditCtrl Pin
Sheng Jiang 蒋晟6-Feb-05 14:11
Sheng Jiang 蒋晟6-Feb-05 14:11 
GeneralHelp with MFC Pin
Muad-Dib6-Feb-05 9:49
Muad-Dib6-Feb-05 9:49 
GeneralRe: Help with MFC Pin
Chris Losinger6-Feb-05 10:32
professionalChris Losinger6-Feb-05 10:32 
QuestionHow to optimize this code? Pin
tttyip6-Feb-05 7:40
tttyip6-Feb-05 7:40 
I am try to calculate 2D convolution and extract the central matrix of the convolution result. Here is my c++ code:

//create the kernel matrix
mxArray *mxKernel = mxCreateNumericMatrix(3, 3, mxDOUBLE_CLASS, mxREAL);
double *Kernel = mxGetPr(mxKernel);



//set the kernel
Kernel[0] = 2; Kernel[3] = 3; Kernel[6] = 1;
Kernel[1] = 0; Kernel[4] = 2; Kernel[7] = 3;
Kernel[2] = 4; Kernel[5] = 2; Kernel[8] = 1;

int Mk = mxGetM(mxKernel);//row of kernel
int Nk = mxGetN(mxKernel);//column of kernel

int M = mxGetM(ImportMatrix);//row of input matrix
int N = mxGetN(ImportMatrix);//column of input matrix
Input = mxGetPr(ImportMatrix);


//create the result matrix with elements 0
ExportMatrix = mxCreateDoubleMatrix(M, N, mxREAL);
Output = mxGetPr(ExportMatrix);

//do the algotithm
int i, j, k1, k2;


for ( i = Mk/2 + 1; i <= M + Mk/2; i++ )//output row
{
for ( j = Nk/2 + 1; j <= N + Nk/2; j++ )//output column
{
for ( k1 = 1; k1 <= Mk; k1++ )
{
for ( k2 = 1; k2 <= Nk; k2++ )
{
if ( ( i + Mk/2 + 1 - k1 >= 1
&& j + Nk/2 + 1 - k2 >= 1)
&& ( i + Mk/2 + 1 - k1 <= M
&& j + Nk/2 + 1 - k2 <= N) )
{
Output[( i - Mk/2 - 1 ) + ( j - Nk/2 - 1 ) * M] +=
Kernel[( k1 - 1 ) + ( k2 - 1 ) * Mk] *
Input[( i - k1 ) + ( j - k2 ) * M];
}
}
}


}
}


my code is quite slow and it is even slower than performing convolution with no extraction of central part. (this means that it is slower even the for loop is less in iterations)

Could anyone point out that how could I optimize this code?
Thanks very much.
AnswerRe: How to optimize this code? Pin
Christian Graus6-Feb-05 9:31
protectorChristian Graus6-Feb-05 9:31 
GeneralRe: How to optimize this code? Pin
Chris Losinger6-Feb-05 10:35
professionalChris Losinger6-Feb-05 10:35 
AnswerRe: How to optimize this code? Pin
Tim Smith6-Feb-05 17:12
Tim Smith6-Feb-05 17:12 
GeneralDisabling linker warning messages Pin
Tom Archer6-Feb-05 4:48
Tom Archer6-Feb-05 4:48 
GeneralToolbar double click Pin
Joris van der Pol6-Feb-05 4:10
Joris van der Pol6-Feb-05 4:10 
GeneralRe: Toolbar double click Pin
Neville Franks6-Feb-05 10:31
Neville Franks6-Feb-05 10:31 
GeneralRe: Toolbar double click Pin
Joris van der Pol8-Feb-05 2:42
Joris van der Pol8-Feb-05 2:42 
GeneralSuppressing AutoRun Programmatically Pin
Steve Messer6-Feb-05 3:46
Steve Messer6-Feb-05 3:46 
GeneralRe: Suppressing AutoRun Programmatically Pin
Blake Miller7-Feb-05 5:04
Blake Miller7-Feb-05 5:04 
GeneralRe: Suppressing AutoRun Programmatically Pin
Steve Messer7-Feb-05 5:15
Steve Messer7-Feb-05 5:15 
GeneralRe: Suppressing AutoRun Programmatically Pin
Blake Miller7-Feb-05 5:19
Blake Miller7-Feb-05 5:19 
GeneralRe: Suppressing AutoRun Programmatically Pin
Steve Messer7-Feb-05 7:13
Steve Messer7-Feb-05 7:13 
GeneralRe: Suppressing AutoRun Programmatically Pin
Steve Messer7-Feb-05 8:23
Steve Messer7-Feb-05 8:23 
Questionis it possible to dynamically add image to menu on Win98? Pin
includeh106-Feb-05 3:26
includeh106-Feb-05 3:26 
AnswerRe: is it possible to dynamically add image to menu on Win98? Pin
Christian Graus6-Feb-05 9:32
protectorChristian Graus6-Feb-05 9:32 
AnswerRe: is it possible to dynamically add image to menu on Win98? Pin
PJ Arends6-Feb-05 9:40
professionalPJ Arends6-Feb-05 9:40 
GeneralRe: is it possible to dynamically add image to menu on Win98? Pin
includeh106-Feb-05 23:16
includeh106-Feb-05 23:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.