If you don't know the size of your matrix at compile time, then you can't.
Instead of dealing with 2D arrays, I suggest you declare a simple Matrix class:
class Matrix
{
public:
int Rows() const { return m_rows; }
int Columns() const { return m_columns; }
double* Data() { return m_data; }
Matrix()
{
m_data = NULL;
m_rows = 0;
m_columns = 0;
}
Matrix(const Matrix& mat)
{
if (mat.Rows() != 0 && mat.Columns() != 0)
{
Alloc(mat.Rows(), mat.Columns());
memcpy(m_data, mat.Data(), m_rows * m_columns * sizeof(double));
}
}
~Matrix()
{
Free();
}
void Alloc(int rows, int columns)
{
Free();
m_data = new[rows * columns];
m_rows = rows;
m_columns = columns;
}
void Free()
{
if (m_data != NULL)
delete [] m_data;
m_data = NULL;
m_rows = 0;
m_columns = 0;
}
double operator[](int k) const { return m_data[k]; }
double& operator[](int k) { return m_values[k]; }
double operator()(int i, int j) const { return m_data[i * m_columns + j]; }
double& operator()(int i, int j) { return m_data[i * m_columns + j]; }
private:
int m_rows, m_columns;
double* m_data;
};
Then, don't forget to pass it by reference (or pointers) to any function, otherwise the copy-constructor will slow down the whole process. Or you can just remove the copy-constructor implementation (but also the destructor to avoid deleting the same pointer twice!)
-----------------
You can also use templates:
template<int SIZE>
void func(double (*rot)[SIZE])
{
}
But I still think the Matrix class is a better solution.