Skip to content
Browse files

throws error in determinant is zero

  • Loading branch information...
1 parent cf27c98 commit 7c285544dd9af01bb61bafe598287b805a4a0369 @fibo committed Jan 26, 2013
Showing with 27 additions and 3 deletions.
  1. +11 −2 lib/Real/GeneralLinearGroup.js
  2. +16 −1 test/Real/GeneralLinearGroup.js
View
13 lib/Real/GeneralLinearGroup.js
@@ -1,15 +1,18 @@
+var util = require('util');
+
var RealSquareMatrix = require('./SquareMatrix.js');
function RealGeneralLinearGroup(order) {
var self = this;
var _order = order;
- self.Matrix = function Matrix() {
+ function Matrix() {
var arg = {};
arg.order = _order;
+
arg.elements = [];
for (var i in arguments) {
arg.elements.push(arguments[i]);
@@ -20,7 +23,13 @@ function RealGeneralLinearGroup(order) {
if (this.determinant().isZero()) throw new Error();
};
- self.Id = self.Identity = function Identity() {return new Matrix()};
+ util.inherits(Matrix, RealSquareMatrix);
+
+ self.Matrix = Matrix;
+
+ function Identity() { return new Matrix() };
+
+ self.Id = self.Identity = Identity;
};
module.exports = RealGeneralLinearGroup;
View
17 test/Real/GeneralLinearGroup.js
@@ -2,13 +2,28 @@
var assert = require('assert');
var algebra = require('../../index.js');
-var GLnR = algebra.Real.GeneralLinearGroup;
+var GLnR = algebra.Real.GeneralLinearGroup;
+var RealSquareMatrix = algebra.Real.SquareMatrix;
+
+var GL2 = new GLnR(2);
describe('RealGeneralLinearGroup', function () {
describe('constructor:', function () {
it('', function () {
});
});
+
+ describe('Matrix', function () {
+ it('is a RealSquareMatrix constructor', function () {
+ var m2 = new GL2.Matrix(1, 2, 3, 4);
+
+ assert.ok(m2 instanceof RealSquareMatrix);
+ });
+
+ it('throws Error', function () {
+ assert.throws(function () { new GL2.Matrix(1, 1, 2, 2); }, Error);
+ });
+ });
});

0 comments on commit 7c28554

Please sign in to comment.
Something went wrong with that request. Please try again.