Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

featurerequest: vectors and matrices #6

Open
jmishra17 opened this issue Aug 17, 2015 · 5 comments
Open

featurerequest: vectors and matrices #6

jmishra17 opened this issue Aug 17, 2015 · 5 comments
Assignees

Comments

@jmishra17
Copy link

Was about to start writing some features for vectors and after looking at some of the code, thought that Vectors should operate on array of expressions as their data type:

For instance,

var Vector = function(args){
    this.vec = [];
    if (Array.isArray(args)){
        args.forEach(function (arg){
            var exp = new Expression(arg);
            this.vec.push(exp);
        });
    } else if(typeof(args) !== "undefined"){
        throw "Expected array of stirngs";
    } 
};

Vector.prototype.add = function(args){
    var otherVec = args;
    if (!(args instanceof Vector)){
        otherVec = new Vector(args);
    }

    if (this.vec.length !== otherVec.vec.length) {
        throw "Unequal lengths";
    }
    var thisVec = this.copy();
    var resultVec = new Vector();
    for (var i = 0; i<thisVec.length; i++){
        var addedExp = thisVec.vec[i].add(otherVec.vec[i]);
        resultVec.push(addedExp);
    }
    return resultVec;
};

Following this logic, nd-vectors or Martrices would operate on the same logic, keeping an array of vectors as their internal data structure.

Any suggestions?

@nicolewhite
Copy link
Owner

I think it makes perfect sense to maintain a Vector as an array of Expressions. That'll make basic operations pretty simple.

@nicolewhite
Copy link
Owner

How are you doing with this? I've been playing around with some code locally but I don't want to step on your toes if you're still working on it.

@jmishra17
Copy link
Author

Actually, you can go ahead and write the feature for this. I have been busy with some other stuff.
I am actually gonna go ahead and add plotting feature for all fractions, equations and expressions.

@jmishra17
Copy link
Author

To add to that, I had a few framework adjustment ideas to suggest if you wanna talk this in detail. We can definitely open a Gitter Chat for this if you like

@nicolewhite
Copy link
Owner

Sure, we're over here: https://gitter.im/nicolewhite/algebra.js

@timrach timrach self-assigned this Oct 20, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants