Skip to content

Commit

Permalink
added group, field, ring element
Browse files Browse the repository at this point in the history
  • Loading branch information
fibo committed Oct 15, 2012
1 parent 45d50cd commit 47dd0ef
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 14 deletions.
18 changes: 18 additions & 0 deletions lib/FieldElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

var util = require('util');

var GroupElement = require('./lib/GroupElement.js');

function FieldElement(arg) {
var self = this;

GroupElement.call(self, arg);
}

FieldElement.prototype = {};

util.inherits(FieldElement, GroupElement);

module.exports = FieldElement;


19 changes: 19 additions & 0 deletions lib/GroupElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

function GroupElement(arg) {
var self = this;

var data = arg.data;
this.getData = function () { return data; }

}

GroupElement.prototype = {
clone: function () {
var arg = {};
arg.data = this.getData();
return new GroupElement(arg);
}
};

module.exports = GroupElement;

4 changes: 3 additions & 1 deletion lib/Real/GeneralLinearGroup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

var util = require('util');

var RealField = require('./Field.js');
var R = new RealField();

Expand All @@ -14,7 +16,7 @@ var RealGeneralLinearGroup = function(order) {
GeneralLinearGroup.call(this, arg);
}

RealGeneralLinearGroup.prototype = GeneralLinearGroup.prototype;
util.inherits(RealGeneralLinearGroup, GeneralLinearGroup);

module.exports = RealGeneralLinearGroup;

6 changes: 3 additions & 3 deletions test/ComplexElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var Complex = algebra.Complex.Element;


describe('ComplexElement', function () {
describe('constructor', function () {
describe('constructor:', function () {
it('accepts 0 arguments', function() {
var z = new Complex();
assert.ok(z instanceof Complex);
Expand All @@ -23,8 +23,8 @@ describe('ComplexElement', function () {
});
});

describe('inherits', function () {
it('from ...', function() {
describe('inheritance:', function () {
it('is a FieldElement', function() {
});
});

Expand Down
28 changes: 28 additions & 0 deletions test/FieldElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

var assert = require('assert');
var algebra = require('../index.js');

var FieldElement = algebra.FieldElement;

describe('FieldElement', function () {
describe('constructor:', function () {
it('', function() {
});
});

describe('inheritance:', function () {
it('is a GroupElement', function() {
});
});

describe('mul()', function () {
it('is an abstract function', function() {
});
});

describe('inv()', function () {
it('is an abstract function', function() {
});
});
});

43 changes: 43 additions & 0 deletions test/GroupElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

var assert = require('assert');
var algebra = require('../index.js');

var GroupElement = algebra.GroupElement;

describe('GroupElement', function () {
describe('constructor:', function () {
it('requires data arg', function() {
var a = new GroupElement({data:0});
assert.ok(a instanceof GroupElement);
});
});

describe('clone()', function () {
it('returns a copy of the object', function() {
// TODO se riesco ad implementare clone a livello di GroupElement
// potrei anche togliere i test dalle classi figlie?
it('is an abstract function', function() {
});
});

describe('eq()', function () {
it('is an abstract function', function() {
});
});

describe('add()', function () {
it('is an abstract function', function() {
});
});

describe('sub()', function () {
it('is an abstract function', function() {
});
});

describe('neg()', function () {
it('is an abstract function', function() {
});
});
});

42 changes: 32 additions & 10 deletions test/RealElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,60 @@
var assert = require('assert');
var algebra = require('../index.js');

var Real = algebra.Real.Element;
var Real = algebra.Real.Element;
var FieldElement = algebra.FieldElement;

describe('RealElement', function () {
describe('constructor', function () {
describe('constructor:', function () {
it('accepts a number as single argument', function() {
var ten = new Real(10);
assert.ok(ten instanceof Real);
});
});

describe('inherits', function () {
it('from ...', function() {
});
});

describe('constructor', function () {
it('', function() {
describe('inheritance:', function () {
it('is a FieldElement', function() {
});
});

describe('clone()', function () {
it('returns a copy of the object', function() {
/*
var x = new Real(-15);
var y = x.clone();
assert.ok(y instanceof Real);
assert.ok(x.eq(y));
*/
});
});

describe('eq()', function () {
describe('eq(<Real>)', function () {
it('returns true if two elements are equal', function() {
/*
var x = new Real(-1);
var y = new Real(-1);
assert.ok(x.eq(y));
assert.ok(y.eq(x));
*/
});
});

describe('add(<Real>)', function () {
it('implements the addition operator', function() {
/*
var x = new Real(2);
var y = new Real(3);
x.add(y);
assert.equals(x.getData(), 5);
*/
});

it('coerces number data type', function() {
/*
var x = new Real(2);
x.add(3);
assert.equals(x.getData(), 5);
*/
});
});

Expand Down
28 changes: 28 additions & 0 deletions test/RingElement.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

var assert = require('assert');
var algebra = require('../index.js');

var RingElement = algebra.RingElement;

describe('RingElement', function () {
describe('constructor:', function () {
it('', function() {
});
});

describe('inheritance:', function () {
it('is a FieldElement', function() {
});
});

describe('mul()', function () {
it('is an abstract function', function() {
});
});

describe('inv()', function () {
it('is an abstract function', function() {
});
});
});

0 comments on commit 47dd0ef

Please sign in to comment.