public void TestAntiSymmetricity()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);
            matrix[1, 3] = 1.0f;

            Assert.AreEqual(-1.0f, matrix[3, 1]);
        }
Example #2
0
        [Test()] public void TestCreateMatrix()
        {
            var matrix1 = new SkewSymmetricSparseMatrix(5);
            var matrix2 = matrix1.CreateMatrix(4, 4);

            Assert.IsInstanceOf(matrix1.GetType(), matrix2);
        }
Example #3
0
        [Test()] public void TestAntiSymmetricity()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);

            matrix[1, 3] = 1.0f;

            Assert.AreEqual(-1.0f, matrix[3, 1]);
        }
        public void TestNonEmptyEntryIDs()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);
            Assert.AreEqual(0, matrix.NonEmptyEntryIDs.Count);

            matrix[3, 1] = 1.0f;
            Assert.AreEqual(2, matrix.NonEmptyEntryIDs.Count);
        }
Example #5
0
 ///
 void InitModel()
 {
     // create data structure
     diff_matrix_like    = new SkewSymmetricSparseMatrix(MaxItemID + 1);
     freq_matrix_like    = new SymmetricSparseMatrix <int>(MaxItemID + 1);
     diff_matrix_dislike = new SkewSymmetricSparseMatrix(MaxItemID + 1);
     freq_matrix_dislike = new SymmetricSparseMatrix <int>(MaxItemID + 1);
     user_average        = new double[MaxUserID + 1];
 }
        [Test()] public void TestNonEmptyEntryIDs()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);

            Assert.AreEqual(0, matrix.NonEmptyEntryIDs.Count);

            matrix[3, 1] = 1.0f;
            Assert.AreEqual(2, matrix.NonEmptyEntryIDs.Count);
        }
        public void TestIsSymmetric()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);
            Assert.IsTrue(matrix.IsSymmetric);

            matrix[1, 3] = 1.0f;
            Assert.IsFalse(matrix.IsSymmetric);

            matrix[1, 3] = 0f;
            Assert.IsTrue(matrix.IsSymmetric);
        }
        public void TestGetSet()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);

            matrix[1, 3] = 1.0f;
            Assert.AreEqual( 1.0f, matrix[1, 3]);
            Assert.AreEqual(-1.0f, matrix[3, 1]);

            matrix[4, 1] = -2.0f;
            Assert.AreEqual(-2.0f, matrix[4, 1]);
            Assert.AreEqual( 2.0f, matrix[1, 4]);
        }
Example #9
0
        [Test()] public void TestIsSymmetric()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);

            Assert.IsTrue(matrix.IsSymmetric);

            matrix[1, 3] = 1.0f;
            Assert.IsFalse(matrix.IsSymmetric);

            matrix[1, 3] = 0f;
            Assert.IsTrue(matrix.IsSymmetric);
        }
Example #10
0
        [Test()] public void TestGetSet()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);

            matrix[1, 3] = 1.0f;
            Assert.AreEqual(1.0f, matrix[1, 3]);
            Assert.AreEqual(-1.0f, matrix[3, 1]);

            matrix[4, 1] = -2.0f;
            Assert.AreEqual(-2.0f, matrix[4, 1]);
            Assert.AreEqual(2.0f, matrix[1, 4]);
        }
Example #11
0
        [Test()] public void TestNumberOfNonEmptyEntries()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);

            Assert.AreEqual(0, matrix.NumberOfNonEmptyEntries);

            matrix[3, 1] = 1.0f;
            Assert.AreEqual(2, matrix.NumberOfNonEmptyEntries);

            matrix[3, 1] = 2.0f;
            Assert.AreEqual(2, matrix.NumberOfNonEmptyEntries);

            matrix[3, 3] = 1.0f;
            Assert.AreEqual(3, matrix.NumberOfNonEmptyEntries);
        }
Example #12
0
        ///
        public override void LoadModel(string file)
        {
            InitModel();

            using ( StreamReader reader = Recommender.GetReader(file, this.GetType()) )
            {
                var global_average = double.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);

                var diff_matrix = (SkewSymmetricSparseMatrix) IMatrixUtils.ReadMatrix(reader, this.diff_matrix);  // TODO take symmetric matrix into account for smaller model files
                var freq_matrix = (SymmetricSparseMatrix<int>) IMatrixUtils.ReadMatrix(reader, this.freq_matrix); // TODO take anti-symmetric matrix into account for smaller model files

                // assign new model
                this.global_average = global_average;
                this.diff_matrix = diff_matrix;
                this.freq_matrix = freq_matrix;
            }
        }
Example #13
0
        ///
        public override void LoadModel(string file)
        {
            InitModel();

            using (StreamReader reader = Recommender.GetReader(file, this.GetType()))
            {
                var global_average = double.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);

                var diff_matrix = (SkewSymmetricSparseMatrix)IMatrixUtils.ReadMatrix(reader, this.diff_matrix);                   // TODO take symmetric matrix into account for smaller model files
                var freq_matrix = (SymmetricSparseMatrix <int>)IMatrixUtils.ReadMatrix(reader, this.freq_matrix);                 // TODO take anti-symmetric matrix into account for smaller model files

                // assign new model
                this.global_average = global_average;
                this.diff_matrix    = diff_matrix;
                this.freq_matrix    = freq_matrix;
            }
        }
Example #14
0
        ///
        public override void LoadModel(string file)
        {
            InitModel();

            using ( StreamReader reader = Model.GetReader(file, this.GetType()) )
            {
                var global_average = float.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);

                var diff_matrix = (SkewSymmetricSparseMatrix) reader.ReadMatrix(this.diff_matrix);
                var freq_matrix = (SymmetricSparseMatrix<int>) reader.ReadMatrix(this.freq_matrix);

                // assign new model
                this.global_average = global_average;
                this.diff_matrix = diff_matrix;
                this.freq_matrix = freq_matrix;
            }
        }
Example #15
0
        ///
        public override void LoadModel(string file)
        {
            InitModel();

            using (StreamReader reader = Model.GetReader(file, this.GetType()))
            {
                var global_average = float.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);

                var diff_matrix = (SkewSymmetricSparseMatrix)reader.ReadMatrix(this.diff_matrix);
                var freq_matrix = (SymmetricSparseMatrix <int>)reader.ReadMatrix(this.freq_matrix);

                // assign new model
                this.global_average = global_average;
                this.diff_matrix    = diff_matrix;
                this.freq_matrix    = freq_matrix;
            }
        }
Example #16
0
        ///
        public override void LoadModel(string file)
        {
            InitModel();

            using (StreamReader reader = Recommender.GetReader(file, this.GetType()))
            {
                var global_average = double.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);

                var diff_matrix_like    = (SkewSymmetricSparseMatrix)IMatrixUtils.ReadMatrix(reader, this.diff_matrix_like);
                var freq_matrix_like    = (SymmetricSparseMatrix <int>)IMatrixUtils.ReadMatrix(reader, this.freq_matrix_like);
                var diff_matrix_dislike = (SkewSymmetricSparseMatrix)IMatrixUtils.ReadMatrix(reader, this.diff_matrix_dislike);
                var freq_matrix_dislike = (SymmetricSparseMatrix <int>)IMatrixUtils.ReadMatrix(reader, this.freq_matrix_dislike);
                var user_average        = VectorUtils.ReadVector(reader);

                // assign new model
                this.global_average      = global_average;
                this.diff_matrix_like    = diff_matrix_like;
                this.freq_matrix_like    = freq_matrix_like;
                this.diff_matrix_dislike = diff_matrix_dislike;
                this.freq_matrix_dislike = freq_matrix_dislike;
                this.user_average        = user_average;
            }
        }
        public void TestNumberOfNonEmptyEntries()
        {
            var matrix = new SkewSymmetricSparseMatrix(5);
            Assert.AreEqual(0, matrix.NumberOfNonEmptyEntries);

            matrix[3, 1] = 1.0f;
            Assert.AreEqual(2, matrix.NumberOfNonEmptyEntries);

            matrix[3, 1] = 2.0f;
            Assert.AreEqual(2, matrix.NumberOfNonEmptyEntries);

            matrix[3, 3] = 0f;
            Assert.AreEqual(2, matrix.NumberOfNonEmptyEntries);
        }
Example #18
0
 void InitModel()
 {
     diff_matrix = new SkewSymmetricSparseMatrix(MaxItemID + 1);
     freq_matrix = new SymmetricSparseMatrix<int>(MaxItemID + 1);
 }
Example #19
0
 void InitModel()
 {
     diff_matrix = new SkewSymmetricSparseMatrix(MaxItemID + 1);
     freq_matrix = new SymmetricSparseMatrix <int>(MaxItemID + 1);
 }
Example #20
0
        [Test()] public void TestNumberOfColumns()
        {
            var matrix = new SkewSymmetricSparseMatrix(3);

            Assert.AreEqual(3, matrix.NumberOfColumns);
        }
Example #21
0
 ///
 void InitModel()
 {
     // create data structure
     diff_matrix_like = new SkewSymmetricSparseMatrix(MaxItemID + 1);
     freq_matrix_like = new SymmetricSparseMatrix<int>(MaxItemID + 1);
     diff_matrix_dislike = new SkewSymmetricSparseMatrix(MaxItemID + 1);
     freq_matrix_dislike = new SymmetricSparseMatrix<int>(MaxItemID + 1);
     user_average = new double[MaxUserID + 1];
 }
 public void TestCreateMatrix()
 {
     var matrix1 = new SkewSymmetricSparseMatrix(5);
     var matrix2 = matrix1.CreateMatrix(4, 4);
     Assert.IsInstanceOfType(matrix1.GetType(), matrix2);
 }
Example #23
0
        ///
        public override void LoadModel(string file)
        {
            InitModel();

            using ( StreamReader reader = Recommender.GetReader(file, this.GetType()) )
            {
                var global_average = double.Parse(reader.ReadLine(), CultureInfo.InvariantCulture);

                var diff_matrix_like = (SkewSymmetricSparseMatrix) IMatrixUtils.ReadMatrix(reader, this.diff_matrix_like);
                var freq_matrix_like = (SymmetricSparseMatrix<int>) IMatrixUtils.ReadMatrix(reader, this.freq_matrix_like);
                var diff_matrix_dislike = (SkewSymmetricSparseMatrix) IMatrixUtils.ReadMatrix(reader, this.diff_matrix_dislike);
                var freq_matrix_dislike = (SymmetricSparseMatrix<int>) IMatrixUtils.ReadMatrix(reader, this.freq_matrix_dislike);
                var user_average = VectorUtils.ReadVector(reader);

                // assign new model
                this.global_average = global_average;
                this.diff_matrix_like = diff_matrix_like;
                this.freq_matrix_like = freq_matrix_like;
                this.diff_matrix_dislike = diff_matrix_dislike;
                this.freq_matrix_dislike = freq_matrix_dislike;
                this.user_average = user_average;
            }
        }
 public void TestNumberOfRows()
 {
     var matrix = new SkewSymmetricSparseMatrix(3);
     Assert.AreEqual(3, matrix.NumberOfRows);
 }