Resizing Boost matrix class member

dear all

i am building a class and one of its private members must be a matrix whose size is not know at the moment the constructor is invoked but later on during the execution of one of the class methods. i have tried declaring an empty Boost matrix as a private member of my class; then, within the method that uses this matrix I use resize to give this matrix it required size. doesn't seem to be working though....

your suggestions are very much appreciated

cheers
Have you considered using a pointer/smart pointer?
There is no problem with boost::numeric::ublas::matrix<>::resize()
http://liveworkspace.org/code/4saDkh$0

The problem lies elsewhere.
Problem solved. I was doing this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#ifndef __CHILLER20_H__
#define __CHILLER20_H__

#include<iostream>
using namespace std;
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

class CChiller 
{

private:
	
	////////////////////////
	// chiller parameters //
	////////////////////////
	
	// chiller fit matrix
	boost::numeric::ublas::matrix<double> mPc_fit();

}
#endif 


when I should have done this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#ifndef __CHILLER20_H__
#define __CHILLER20_H__

#include<iostream>
using namespace std;
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

class CChiller 
{

private:
	
	////////////////////////
	// chiller parameters //
	////////////////////////
	
	// chiller fit matrix
	boost::numeric::ublas::matrix<double> mPc_fit;

}
#endif 


I then used resize to allocate the required number of rows and columns.

Cheers,

Little
Topic archived. No new replies allowed.