I'm creating a matrix class so I already have a
public double this[int row, col]
but I'd also want to easily set and get a particular row or column in a similar fashion. I currently have:
public virtual Vector GetRow(int row)
{
return m[row];
}
public virtual void SetRow(int row, Vector v)
{
m[row] = v;
}
public virtual Vector GetCol(int col)
{
return Transpose().m[col];
}
public virtual void SetCol(int col, Vector v)
{
Matrix temp = Transpose();
temp.SetRow(col, v);
temp = temp.Transpose();
m = temp.m;
}
but what I want is something like:
public virtual Vector Row(int row)
{
get => return m[row];
set => m[row] = value;
}
public virtual Vector Col(int col)
{
// getter and setter logic here
}
is there a way to do this? or do I absolutely NEED to use the methods I've created? I know that I could do the row OR the column the way that I want, but, not both I don't think.