Ejemplo n.º 1
0
        /// <summary>
        /// Retransforms this instance.
        /// </summary>
        /// <returns></returns>
        public DataMatrix Retransform(int levelCount)
        {
            var matrix = new DataMatrix(MatrixType.Retransformed, this.ColumnCount);

            foreach (DataRow row in this.Rows)
            {
                int halfGroupCount = this.ColumnCount;

                var tmpRow = row.RowValues.ToArray();
                for (int currentLevel = 0; currentLevel < levelCount; currentLevel++)
                {
                    halfGroupCount = halfGroupCount / 2;
                    int groupLen = Convert.ToInt32(Math.Pow(2.0, currentLevel));
                    for (int j = 0; j < halfGroupCount; j++)
                    {
                        var r = tmpRow.ToList().ToArray();
                        var s = tmpRow.ToList().ToArray();

                        var groupOffset = (this.ColumnCount * j) / halfGroupCount;
                        for (int i = 0; i < groupLen; i++)
                        {
                            var a = tmpRow[groupOffset + i];
                            var d = tmpRow[groupOffset + groupLen + i];

                            r[i] = (a + d) / Math.Sqrt(2.0);
                            s[i] = (a - d) / Math.Sqrt(2.0);

                            // r[i] = (tmpRow[p + i] + tmpRow[p + h + i]) / Math.Sqrt(2.0);
                            // s[i] = (tmpRow[p + i] - tmpRow[p + h + i]) / Math.Sqrt(2.0);
                        }


                        for (int i = 0; i < groupLen; i++)
                        {
                            tmpRow[groupOffset + (2 * i)]     = r[i];
                            tmpRow[groupOffset + (2 * i) + 1] = s[i];
                        }
                    }
                }

                for (int i = 0; i < tmpRow.Count(); i++)
                {
                    tmpRow[i] = Math.Round(tmpRow[i], 0);
                }

                var nr = new DataRow(tmpRow);
                matrix.Rows.Add(nr);
            }

            return(matrix);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retransforms this instance.
        /// </summary>
        /// <returns></returns>
        public DataMatrix Retransform(int levelCount)
        {
            var matrix = new DataMatrix(MatrixType.Retransformed, this.ColumnCount);

            foreach (DataRow row in this.Rows)
            {
                int halfGroupCount = this.ColumnCount;

                var tmpRow = row.RowValues.ToArray();
                for (int currentLevel = 0; currentLevel < levelCount; currentLevel++)
                {
                    halfGroupCount = halfGroupCount / 2;
                    int groupLen = Convert.ToInt32(Math.Pow(2.0, currentLevel));
                    for (int j = 0; j < halfGroupCount; j++)
                    {
                        var r = tmpRow.ToList().ToArray();
                        var s = tmpRow.ToList().ToArray();

                        var groupOffset = (this.ColumnCount * j) / halfGroupCount;
                        for (int i = 0; i < groupLen; i++)
                        {
                            var a = tmpRow[groupOffset + i];
                            var d = tmpRow[groupOffset + groupLen + i];

                            r[i] = (a + d) / Math.Sqrt(2.0);
                            s[i] = (a - d) / Math.Sqrt(2.0);

                            // r[i] = (tmpRow[p + i] + tmpRow[p + h + i]) / Math.Sqrt(2.0);
                            // s[i] = (tmpRow[p + i] - tmpRow[p + h + i]) / Math.Sqrt(2.0);
                        }

                        for (int i = 0; i < groupLen; i++)
                        {
                            tmpRow[groupOffset + (2 * i)] = r[i];
                            tmpRow[groupOffset + (2 * i) + 1] = s[i];
                        }

                    }
                }

                for (int i = 0; i < tmpRow.Count(); i++)
                {
                    tmpRow[i] = Math.Round(tmpRow[i], 0);
                }

                var nr = new DataRow(tmpRow);
                matrix.Rows.Add(nr);
            }

            return matrix;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The transform single step.
        /// </summary>
        /// <param name="row">The row.</param>
        /// <param name="step">The step.</param>
        /// <returns></returns>
        public List<DataGroup> TransformSingleStep(int row, int step)
        {
            var matrixOrig = new DataMatrix(this.UntransformedAsciiFilePath);
            Trace.WriteLine(string.Format("Original matrix ascii import completed, imported {0} rows.", matrixOrig.Rows.Count));

            var dataRow = matrixOrig.Rows[row];
            var groups = dataRow.CalculateTransformedGroups(step);
            return groups;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Transforms all rows.
        /// </summary>
        public void TransformAllRows()
        {
            this.OriginalMatrix = new DataMatrix(this.UntransformedAsciiFilePath);
            Trace.WriteLine(string.Format("Original matrix ascii import completed, imported {0} rows.", this.OriginalMatrix.Rows.Count));

            var matrixTrans = new DataMatrix(MatrixType.Transformed, this.OriginalMatrix.ColumnCount);

            // transform row by row
            for (int i = 0; i < this.OriginalMatrix.Rows.Count; i++)
            {
                // use the required level
                var groups = this.OriginalMatrix.Rows[i].CalculateTransformedGroups(this.OriginalMatrix.MaxLevelCount);
                matrixTrans.Rows.Add(new DataRow(groups));
            }

            // create output ascii file for transformed matrix
            matrixTrans.WriteToAsciiFile(this.TransformedAsciiFilePath);

            this.TransformedMatrix = matrixTrans;
        }