/**
 * Created by Peter Trebing on 28/12/14.
 */
QUnit.test( "vector copy", function( assert ) {

    // testing copy
    assert.ok(JSON.stringify(LA.vector.copy([1, 1], [2, 2])) === JSON.stringify([1, 1]));
    assert.ok(JSON.stringify(LA.vector.copy([1], [2, 2])) === JSON.stringify([1]));
    assert.ok(JSON.stringify(LA.vector.copy([1, 1], [2])) === JSON.stringify([1, 1]));
    assert.ok(JSON.stringify(LA.vector.copy([1], [])) === JSON.stringify([1]));

});

QUnit.test( "Vector addition", function( assert ) {

    // testing vector addition
    assert.ok(JSON.stringify(LA.vector.add([1, 1], [2, 2])) === JSON.stringify([3, 3]));
    assert.ok(JSON.stringify(LA.vector.add([1], [2, 2])) === JSON.stringify([3, 2]));
    assert.ok(JSON.stringify(LA.vector.add([1, 1], [2])) === JSON.stringify([3, 1]));
    assert.ok(JSON.stringify(LA.vector.add([1], [])) === JSON.stringify([1]));

});

QUnit.test( "vector axpy", function( assert ) {

    // testing axpy
    assert.ok(JSON.stringify(LA.vector.axpy(1.0, [1, 1], [2, 2])) === JSON.stringify([3, 3]));
    assert.ok(JSON.stringify(LA.vector.axpy(2.0, [1], [2, 2])) === JSON.stringify([4, 2]));
    assert.ok(JSON.stringify(LA.vector.axpy(3.0, [1, 1], [2])) === JSON.stringify([5, 3]));
    assert.ok(JSON.stringify(LA.vector.axpy(4.0, [1], [])) === JSON.stringify([4]));

});

QUnit.test( "vector dot product", function( assert ) {

    // testing dot product
    assert.ok(JSON.stringify(LA.vector.dot([1, 1], [2, 2])) === JSON.stringify(4));
    assert.ok(JSON.stringify(LA.vector.dot([1], [2, 2])) === JSON.stringify(2));
    assert.ok(JSON.stringify(LA.vector.dot([1, 1], [2])) === JSON.stringify(2));
    assert.ok(JSON.stringify(LA.vector.dot([0, 1, 0], [1, 1, 1])) === JSON.stringify(1));
    assert.ok(JSON.stringify(LA.vector.dot([1, 1, 1], [0, 0, 0])) === JSON.stringify(0));

});

QUnit.test( "vector scaling", function( assert ) {

    // testing scaling
    assert.ok(JSON.stringify(LA.vector.scale(3, [1, 1])) === JSON.stringify([3, 3]));
    assert.ok(JSON.stringify(LA.vector.scale(1, [2, 2])) === JSON.stringify([2, 2]));
    assert.ok(JSON.stringify(LA.vector.scale(0.5, [2, 2])) === JSON.stringify([1, 1]));
    assert.ok(JSON.stringify(LA.vector.scale(0, [2, 2])) === JSON.stringify([0, 0]));

});

QUnit.test( "vector norm2", function( assert ) {

    // testing norm2
    assert.ok(JSON.stringify(LA.vector.norm2([1, 1, 1, 1])) === JSON.stringify(2));
    assert.ok(JSON.stringify(LA.vector.norm2([1, 0, 0, 0, 0, 0])) === JSON.stringify(1));
    assert.ok(JSON.stringify(LA.vector.norm2([0, 0, 0, 0, 0, 1])) === JSON.stringify(1));
    assert.ok(JSON.stringify(LA.vector.norm2([0, 0, 1, 0, 0, 0])) === JSON.stringify(1));
    assert.ok(JSON.stringify(LA.vector.norm2([Math.sqrt(2), Math.sqrt(2)])) === JSON.stringify(2));

});

QUnit.test( "vector orthogonality", function( assert ) {

     // check isOrthogonal
    assert.ok(LA.vector.isOrthogonal([1, 0, 0], [0, 1, 0]));
    assert.ok(LA.vector.isOrthogonal([1, 0, 0], [0, 0, 1]));

    assert.ok(LA.vector.isOrthogonal([0, 1, 0], [1, 0, 0]));
    assert.ok(LA.vector.isOrthogonal([0, 1, 0], [0, 0, 1]));

    assert.ok(LA.vector.isOrthogonal([0, 0, 1], [0, 1, 0]));
    assert.ok(LA.vector.isOrthogonal([0, 0, 1], [1, 0, 0]));

});

QUnit.test( "vector cosinus theta", function( assert ) {

    // check cosThetha
    assert.ok(LA.vector.cosThetha([1, 0, 0], [0, 1, 0]) === 0); //Thetha = 90 degree

});