コード例 #1
0
ファイル: Fraction.cs プロジェクト: AM636E/dotNet
        /*public Fraction Mul(double num)
        {
            return new Fraction(this.number * num);
        }
        */
        public Fraction Div(Fraction f)
        {
            if (f.number != 0)
            {
                return new Fraction(this.number / f.number);
            }

            return new Fraction(2);
        }
コード例 #2
0
ファイル: Fraction.cs プロジェクト: AM636E/dotNet
 public Fraction Sub(Fraction f)
 {
     return new Fraction(this.number - f.number);
 }
コード例 #3
0
ファイル: Fraction.cs プロジェクト: AM636E/dotNet
 Fraction(Fraction f)
 {
     this.whole = f.whole;
     this.fractional = f.fractional;
     this.number = f.number;
 }
コード例 #4
0
ファイル: Fraction.cs プロジェクト: AM636E/dotNet
 public Fraction Add(Fraction f)
 {
     return new Fraction(this.number + f.number);
 }
コード例 #5
0
        public void MatrixAddMatrixMulVectorTest(int testCount)
        {
            // ---------------------------------------------------------
            // fraction
            // ---------------------------------------------------------
            _time = new TimeSpan();
            var frResult = new Fraction[0];

            for (var i = 0; i < testCount; i++)
            {
                var frA = new MyMatrix <Fraction>(SfrA);
                var frB = new MyMatrix <Fraction>(SfrB);
                var frC = new MyMatrix <Fraction>(SfrC);
                var frX = SfrX;

                _stopwatch.Reset();
                _stopwatch.Start();
                frResult = (frA + frB + frC) * frX;
                _stopwatch.Stop();
                _time += _stopwatch.Elapsed;
            }

            _handler.WriteToFileWithTimespan(
                IO.PrefixFraction + IO.ResultAbcx,
                MyMatrixFormatter.GetFormattedVector(frResult),
                CurrentMatrixSize,
                _time.TotalMilliseconds / testCount);


            // ---------------------------------------------------------
            // float
            // ---------------------------------------------------------
            _time = new TimeSpan();
            var fResult = new float[0];

            for (var i = 0; i < testCount; i++)
            {
                var fA = new MyMatrix <float>(SfA);
                var fB = new MyMatrix <float>(SfB);
                var fC = new MyMatrix <float>(SfC);
                var fX = SfX;

                _stopwatch.Reset();
                _stopwatch.Start();
                fResult = (fA + fB + fC) * fX;
                _stopwatch.Stop();
                _time += _stopwatch.Elapsed;
            }

            _handler.WriteToFileWithTimespan(
                IO.PrefixFloat + IO.ResultAbcx,
                MyMatrixFormatter.GetFormattedVector(fResult),
                CurrentMatrixSize,
                _time.TotalMilliseconds / testCount);


            // ---------------------------------------------------------
            // double
            // ---------------------------------------------------------
            _time = new TimeSpan();
            var dResult = new double[0];

            for (var i = 0; i < testCount; i++)
            {
                var dA = new MyMatrix <double>(SdA);
                var dB = new MyMatrix <double>(SdB);
                var dC = new MyMatrix <double>(SdC);
                var dX = SdX;

                _stopwatch.Reset();
                _stopwatch.Start();
                dResult = (dA + dB + dC) * dX;
                _stopwatch.Stop();
                _time += _stopwatch.Elapsed;
            }

            _handler.WriteToFileWithTimespan(
                IO.PrefixDouble + IO.ResultAbcx,
                MyMatrixFormatter.GetFormattedVector(dResult),
                CurrentMatrixSize,
                _time.TotalMilliseconds / testCount);
        }