Matrix Representations of Algebraic Varieties: Matrix-based implicit representations of algebraic curves and surfaces and applications