I am pretty new to vue.js, so I'm not even sure if what I'm trying to do is possible. I am working on developing a Matrix component that I could then use in other applications. My problem is that I would like for the getIdentity() method to return a new Matrix component with an array passed into it
export default {
name: 'Matrix',
props: {
initRows: Number,
initColumns: Number,
initValues: Array
},
data () {
return {
editable: true,
contents: [],
rows: 1,
columns: 1
}
},
created () {
...
},
methods: {
addColumn () {...},
removeColumn (column) {...},
addRow () {...},
removeRow (row) {...},
getRREF () {...},
getInverse () {...},
getIdentity () {
if (this.rows === this.columns) {
let tempMtx = [];
for (let row = 0; row < this.rows; row++) {
tempMtx[row] = [];
for (let col = 0; col < this.columns; col++) {
tempMtx[row][col] = row === col ? 1 : 0;
}
}
return new Matrix({propsData: {initValues: tempMtx}}); // This is the part I can't figure out
} else {
throw new Error('Rows and Columns must be equal to get the identity matrix');
}
}
}
}