Click here to Skip to main content
15,918,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Unwanted color change when Edit box is ReadOnly Pin
Aidman30-Jul-03 8:20
Aidman30-Jul-03 8:20 
GeneralRe: Unwanted color change when Edit box is ReadOnly Pin
John M. Drescher30-Jul-03 15:06
John M. Drescher30-Jul-03 15:06 
GeneralChild dialogs in Win32 Pin
bluecombtiller30-Jul-03 7:06
bluecombtiller30-Jul-03 7:06 
GeneralRe: Child dialogs in Win32 Pin
l a u r e n30-Jul-03 7:21
l a u r e n30-Jul-03 7:21 
GeneralRe: Child dialogs in Win32 Pin
bluecombtiller31-Jul-03 7:10
bluecombtiller31-Jul-03 7:10 
GeneralRe: Child dialogs in Win32 Pin
andyj1151-Aug-03 4:30
andyj1151-Aug-03 4:30 
GeneralRe: Child dialogs in Win32 Pin
bluecombtiller1-Aug-03 9:13
bluecombtiller1-Aug-03 9:13 
GeneralDynamic array initialization. Pin
73Zeppelin30-Jul-03 6:37
73Zeppelin30-Jul-03 6:37 
I have a member variable of a class declared as a pointer to type double, m_dHessianMatrix. This variable will be holding a 2 x 2 matrix (could be larger)and needs to be initialized completely to zeroes to start. As such, I need something to init the matrix to zero quickly (thus a for loop will not do particularly for LARGE matrices).

Currently I am initializing the matrix data in the constructor as follows:
//////////////////////////////////////////////////////
// CROT_Optimizer()
//
// NOTES: Constructs a ROT_Optimizer object
//        to be used as the quasi-Newton 
//        nonlinear optimization engine
//
// ACCEPTS: The number of nodes in the springs
//			network to be optimized
//
// RETURNS:
//
CROT_Optimizer::CROT_Optimizer(UINT MaxNodes)
{
	ASSERT (MaxNodes > 0);

	if (MaxNodes == 0)
		return;

	m_uiNumberOfNodes = MaxNodes;	// we NEED the number of nodes
	m_uiNumberOfSprings = 0;

	// Pointer initializations
	m_ppNodeIndexedSpringArray = NULL;
	m_dHessianMatrix = NULL;

	m_dHessianMatrix = new double[4];  // a 2 x 2 matrix
	memset(m_dHessianMatrix, 0, sizeof(double));

}


However, I don't like this for two reasons.

1.) I have to include string.h to gain access to the memset function ->code bloat Dead | X|
2.) It is not aesthetically pleasing to the eye Cool | :cool:

Is there a way to initialize the matrix without using a for loop and without using memset()?
GeneralRe: Dynamic array initialization. Pin
John M. Drescher30-Jul-03 6:39
John M. Drescher30-Jul-03 6:39 
GeneralRe: Dynamic array initialization. Pin
73Zeppelin30-Jul-03 6:49
73Zeppelin30-Jul-03 6:49 
GeneralRe: Dynamic array initialization. Pin
John M. Drescher30-Jul-03 6:54
John M. Drescher30-Jul-03 6:54 
GeneralMFC/ATL thread syncronization Pin
alma30-Jul-03 6:26
alma30-Jul-03 6:26 
GeneralRe: MFC/ATL thread syncronization Pin
John M. Drescher30-Jul-03 6:37
John M. Drescher30-Jul-03 6:37 
GeneralRe: MFC/ATL thread syncronization Pin
alma30-Jul-03 11:19
alma30-Jul-03 11:19 
GeneralAbstract Class Pin
Mahesh Varma30-Jul-03 5:43
Mahesh Varma30-Jul-03 5:43 
GeneralRe: Abstract Class Pin
#realJSOP30-Jul-03 5:47
professional#realJSOP30-Jul-03 5:47 
GeneralRe: Abstract Class Pin
Jonathan de Halleux30-Jul-03 5:49
Jonathan de Halleux30-Jul-03 5:49 
GeneralRe: Abstract Class Pin
ZoogieZork30-Jul-03 6:16
ZoogieZork30-Jul-03 6:16 
GeneralRe: Abstract Class Pin
John M. Drescher30-Jul-03 6:54
John M. Drescher30-Jul-03 6:54 
GeneralRe: Abstract Class Pin
Mahesh Varma30-Jul-03 19:03
Mahesh Varma30-Jul-03 19:03 
GeneralRe: Abstract Class Pin
Navin30-Jul-03 6:31
Navin30-Jul-03 6:31 
GeneralRe: Abstract Class Pin
melwyn30-Jul-03 21:51
melwyn30-Jul-03 21:51 
GeneralRe: Abstract Class Pin
ZoogieZork30-Jul-03 9:37
ZoogieZork30-Jul-03 9:37 
Generalwindows message maps Pin
Chris Eatough30-Jul-03 5:13
Chris Eatough30-Jul-03 5:13 
GeneralRe: windows message maps Pin
John M. Drescher30-Jul-03 5:26
John M. Drescher30-Jul-03 5:26 

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.