Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

farmerdoug

macrumors 6502a
Original poster
Sep 16, 2008
541
0
Using C++, I have to create a vector x using MatDoub several times over as I need to specify the exact value of k each time.
Below is the output of the search for all the instances of MatDoub in the code.

Can anybody tell me how to free x?
thanks


Code:
main.cpp:     MatDoub x(k,ndim);
krig.h: 	const MatDoub &x;
krig.h: 	MatDoub v;
krig.h: 	Krig(MatDoub_I &xx, VecDoub_I &yy, T &vargram, const Doub *err=NULL)
krig.h: 	Powvargram(MatDoub_I &x, VecDoub_I &y, const Doub beta=1.5, const Doub nug=0.)
interp_2d.h: 	const MatDoub &y;
interp_2d.h: 	Bilin_interp(VecDoub_I &x1v, VecDoub_I &x2v, MatDoub_I &ym)
interp_2d.h: 	const MatDoub &y;
interp_2d.h: 	Poly2D_interp(VecDoub_I &x1v, VecDoub_I &x2v, MatDoub_I &ym,
interp_2d.h: 	const MatDoub &y;
interp_2d.h: 	Spline2D_interp(VecDoub_I &x1v, VecDoub_I &x2v, MatDoub_I &ym)
interp_2d.h: 	const Doub d1, const Doub d2, MatDoub_O &c) {
interp_2d.h: 	MatDoub c(4,4);
LUdcmp.h: 	MatDoub lu;
LUdcmp.h: 	LUdcmp(MatDoub_I &a);
LUdcmp.h: 	void solve(MatDoub_I &b, MatDoub_O &x);
LUdcmp.h: 	void solve(MatDoub_I &b, MatDoub_O &x);
LUdcmp.h: 	void inverse(MatDoub_O &ainv);
LUdcmp.h: 	MatDoub_I &aref;
LUdcmp.h: LUdcmp::LUdcmp(MatDoub_I &a) : n(a.nrows()), lu(a), aref(a), indx(n) {
LUdcmp.h: void LUdcmp::solve(MatDoub_I &b, MatDoub_O &x)
LUdcmp.h: void LUdcmp::solve(MatDoub_I &b, MatDoub_O &x)
LUdcmp.h: void LUdcmp::inverse(MatDoub_O &ainv)
nr3.h: typedef const NRmatrix<Doub> MatDoub_I;
nr3.h: typedef NRmatrix<Doub> MatDoub, MatDoub_O, MatDoub_IO;
nr3.h: typedef NRmatrix<Doub> MatDoub, MatDoub_O, MatDoub_IO;
nr3.h: typedef NRmatrix<Doub> MatDoub, MatDoub_O, MatDoub_IO;
 
I can send you more code but I thought having all the lines with and definitions of MatDoub would be sufficient. In any event
delete [k,ndim] compiles.
as does
delete &y[k] compiles for VecDoub. However both fail when the code runs.

Can you tell me if any of the h files like it would be helpful.
 
Looks like you simply grepped through your code for "MatDoub" [edit: never mind, you explicitly told us you did this]. You mention a MatDoub called "x", which seems to be the first line in your grep output. If that's the case, it looks like it's being created on the stack, not the heap - in that case, you don't need to delete it at all. It will just automatically vanish at the end of its scope.

This is the most important feature of C++, in my opinion.

Your example use of delete looks quite dangerous.
 
chown.

I know we've been down this path before. :)
I've been working in C but found the answer I needed in the newest version of Numerical Recipes now written in C++.
Cut, paste, make some errors, post some questions, make it work, move on.
 
chown.

I know we've been down this path before. :)
I've been working in C but found the answer I needed in the newest version of Numerical Recipes now written in C++.
Cut, paste, make some errors, post some questions, make it work, move on.

Farmerdoug, I hope I'm not out of line when I call you the Glenn Beck of the MR:programming forum.

Not accusing, just asking questions.
 
Jared.
Don't know why you would think you are out of line but I don't get the comparison either. I'm not thin skinned either.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.