Simown, on 23 July 2012 - 06:47 AM, said:

Look at section 2.4 here: Python __Underscore__ Methods

Edit: Maybe that's not right, you want to override the assignment operator "="? Wouldn't that making assigning to other variables a little tricky?

Edit again, more thinking:

What if you assigned to the matrix in your __init__ method? i.e.:

class Matrix: def __init__(self, matrix): self.N = len(matrix) self.M = len(matrix[0]) # assuming they are all the same length, you should probably check self.matrix = checkMatrix(matrix) def checkMatrix(matrix): # is it a valid matrix? Checks and validation

Then you can just make a new matrix:

m = Matrix([[1,2,3], [4,5,6], [7,8,9]])

Is there a reason it is full of zeros to begin with?

The zeroes were just a default blank matrix. I guess your way is a better way of doing it. No point in declaring the dimensions separately since you can already do it when defining the matrix.

I'll work more on it tonight.

That hardest part should be coming up with an algorithm to find the inverse and the determinant of the matrix. I think there's a formula for the inverse but I want to come up with the algorithm to find determinants on my own (I love reinventing the wheel) based on what I learned in linear algebra.

This post has been edited by **carnivroar**: 23 July 2012 - 11:11 AM