I have a matrix class in C++ and the constructor is as follows:
template <typename T> CMatrix<T>::CMatrix(unsigned int varrow,unsigned int varcolumn)
{
//Lets set member variables
this->m_row=varrow;this->m_column=varcolumn;
//Create a place holder at heap
m_matrix=new T[varrow*varcolumn];
//
unsigned int i=0;
//
//Default matrix All elements are zero
for(i=0;i<varrow*varcolumn;i++)
{
m_matrix[i]=T();
}
//
}
I have implemented set and get methods as follows:
void SetCellValue(unsigned int row,unsigned int col,T value){ m_matrix[row*m_column+col]=value;}
T& GetCellValue(unsigned int row,unsigned int column) const{return m_matrix[row*m_column+column];}
The matrix class is accessible from Lua; however, the only way I can access to elements of matrix from Lua is, say if m is a matrix, m:GetValue or m:SetValue.
I want to know whether it is possible to access (set) matrix elements by a notation m[1,2] or maybe m(1,2) where m is a matrix, [1,2] is the element at first row and second column.