コード例 #1
0
ファイル: PiSymbol.cs プロジェクト: samphippen/precmaths
 public override Rational EvaluateRational(int Precision)
 {
     if (this.power == 0)
     {
         return 1;
     }
     else if (this.power == 1)
     {
         return this.PiSeries(Precision);
     }
     else if (this.power == -1)
     {
         return 1 / this.PiSeries(Precision);
     }
     else if (this.power < -1)
     {
         Rational newpower = new Rational(this.power.Numerator.Number, this.power.Denominator.Number);
         Rational flippedpiseries = 1 / this.PiSeries(Precision);
         return PowerEvaluation.EvaluateRationalPower(flippedpiseries, newpower, Precision);
     }
     else
     {
         return PowerEvaluation.EvaluateRationalPower(this.PiSeries(Precision), this.power, Precision);
     }
 }
コード例 #2
0
ファイル: DisplayMode.cs プロジェクト: GrafSeismo/SharpDX
 /// <summary>Initializes a new instance of the <see cref="DisplayMode"/> class.</summary>
 /// <param name="pixelFormat">The pixel format.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="refreshRate">The refresh rate.</param>
 public DisplayMode(Format pixelFormat, int width, int height, Rational refreshRate)
 {
     this.pixelFormat = pixelFormat;
     this.width = width;
     this.height = height;
     this.refreshRate = refreshRate;
 }
コード例 #3
0
        public static void ProcessFiles(FileInfo[] files, int speedupFactor, Rational outputFramesPerSecond)
        {
            var i = 1;
            var filesCount = files.Count();
            var engine = new HyperlapseEngine();

            engine.ProcessingCancelled += OnEngineProcessingCancelled;
            engine.ProcessingFailed += OnEngineProcessingFailed;
            engine.ProcessingFinished += OnEngineProcessingFinished;
            engine.ProgressChanged += OnEngineProgressChanged;
            engine.TrialStatusChanged += OnEngineTrialStatusChanged;

            foreach (var file in files)
            {
                var processingMsg = "[Processing file " + i++ + " of " + filesCount + "] - " + file.Name;
                Console.Title = processingMsg;
                Console.WriteLine(processingMsg);

                var fileOutput = new FileInfo(Path.Combine(file.DirectoryName, "Output", file.Name));
                if (!fileOutput.Directory.Exists)
                {
                    fileOutput.Directory.Create(); // create output dir
                }

                Process(engine, file, fileOutput, speedupFactor, outputFramesPerSecond);
            }

            engine.Dispose();
        }
コード例 #4
0
ファイル: task1.cs プロジェクト: seniorivn/ITMO
 public static Rational Normalize(Rational a)
 {
     int numenator = a.GetNumenator();
     int denumenator = a.GetDenumenator();
     int gcd = GCD(numenator, denumenator);
     return new Rational(numenator / gcd, denumenator / gcd);
 }
コード例 #5
0
 public void TestGetReciprocal()
 {
     var rational = new Rational(1, 3);
     var reciprocal = rational.Reciprocal;
     Assert.Equal(new Rational(3, 1), reciprocal);
     Assert.Equal(new Rational(1, 3), rational);
 }
コード例 #6
0
        public void TestToSimpleString()
        {
            var third1 = new Rational(1, 3);
            var third2 = new Rational(2, 6);
            Assert.Equal("1/3", third1.ToSimpleString());
            Assert.Equal("1/3", third2.ToSimpleString());
            Assert.Equal(third1, third2);

            var twoThirds = new Rational(10, 15);
            Assert.Equal("2/3", twoThirds.ToSimpleString());

            var two = new Rational(10, 5);
            Assert.True(two.IsInteger);
            Assert.Equal("2", two.ToSimpleString());
            Assert.Equal("2", two.ToSimpleString(allowDecimal: false));

            var twoFifths = new Rational(4, 10);
            Assert.Equal("0.4", twoFifths.ToSimpleString());
            Assert.Equal("2/5", twoFifths.ToSimpleString(allowDecimal: false));

            var threeEighths = new Rational(3, 8);
            Assert.Equal("3/8", threeEighths.ToSimpleString());

            var zero = new Rational(0, 8);
            Assert.True(zero.IsInteger);
            Assert.Equal("0", zero.ToSimpleString());
            Assert.Equal("0", zero.ToSimpleString(allowDecimal: false));

            zero = new Rational(0, 0);
            Assert.True(zero.IsInteger);
            Assert.Equal("0", zero.ToSimpleString());
            Assert.Equal("0", zero.ToSimpleString(allowDecimal: false));
        }
コード例 #7
0
 public void TestMultiply_WithOtherRational_Passed()
 {
     var rat = new Rational(625, 5);
     var other = new Rational(338, 13);
     var mult = rat * other;
     Assert.AreEqual(3250, (double)mult, "Invalid multiply operation");
 }
コード例 #8
0
 private static void TestValue(ExifValue value, Rational[] expected)
 {
   Assert.IsNotNull(value);
   Rational[] values = (Rational[])value.Value;
   Assert.IsNotNull(values);
   CollectionAssert.AreEqual(expected, values);
 }
コード例 #9
0
 public void TestCompare_withDoubleFloatInt_Passed()
 {
     var rat = new Rational(625, 5);
     Assert.AreEqual(125, (double)rat, "Invalid cast to double");
     Assert.AreEqual(125, (float)rat, "Invalid cast to float");
     Assert.AreEqual(125, (int)rat, "Invalid cast to int");
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: jschlitz/SupportVec2
 private static Datum[] Generate(int count, Rational w0, Rational[] w)
 {
     return Enumerable.Range(1, count)
     .Select(_ => GetX())
     .Select(ex => new Datum{x=ex, y=GetY(ex, w0, w)})
     .ToArray();
 }
コード例 #11
0
 public void TestAdd_WithOtherRational_Passed()
 {
     var rat = new Rational(625, 5);
     var other = new Rational(338, 13);
     var sum = rat + other;
     Assert.AreEqual(151, (double)sum, "Invalid Sum operation");
 }
コード例 #12
0
ファイル: RationalTest.cs プロジェクト: rettour/Labs
 public void CompareToTest()
 {
     Rational target = new Rational(1, 3);
     Assert.AreEqual(target.CompareTo(new Rational(1, 2)), -1);
     Assert.AreEqual(target.CompareTo(new Rational(1, 3)), 0);
     Assert.AreEqual(target.CompareTo(new Rational(1, 4)), 1);
 }
コード例 #13
0
 public void TestMinus_WithOtherRational_Passed()
 {
     var rat = new Rational(625, 5);
     var other = new Rational(338, 13);
     var minus = rat - other;
     Assert.AreEqual(99, (double)minus, "Invalid minus operation");
 }
コード例 #14
0
 public void TestDivide_WithOtherRational_Passed()
 {
     var rat = new Rational(7, 5);
     var other = new Rational(5, 7);
     var div = rat / other;
     Assert.AreEqual(49, div.Numerator, "Invalid divide operation");
     Assert.AreEqual(25, div.Denominator, "Invalid divide operation");
 }
コード例 #15
0
        public void TestCreateRational()
        {
            var rational = new Rational(1, 3);

            Assert.Equal(1, rational.Numerator);
            Assert.Equal(3, rational.Denominator);
            Assert.Equal(1d / 3d, rational.ToDouble(), 4);
        }
コード例 #16
0
ファイル: RationalTests.cs プロジェクト: dlemstra/Magick.NET
    public void Test_ToDouble()
    {
      Rational rational = new Rational(0, 0);
      Assert.AreEqual(double.NaN, rational.ToDouble());

      rational = new Rational(2, 0);
      Assert.AreEqual(double.PositiveInfinity, rational.ToDouble());
    }
コード例 #17
0
        public static Rational EvaluateRationalPower(Rational a, Rational power,int precision)
        {
            if (a < 0)
            {
                throw new NotImplementedException("exponentation of negative numbers not yet supported");
            }
            SignedBigInteger normalexponentiations = power.Numerator / power.Denominator;
            SignedBigInteger funkyexponentiation = power.Numerator % power.Denominator;
            Rational result;
            if (normalexponentiations > 0)
            {
                result = a.Clone();
                for (int i = 1; i < normalexponentiations; i++)
                {
                    result *= a;
                }
            }
            else
            {
                result = 1;
            }
            Rational upperbound;
            if (a > 1)
            {
                upperbound = a.Clone();
            }
            else
            {
                upperbound = new Rational(a.Denominator, a.Numerator);
            }
            SignedBigInteger flippedtarget = power.Denominator;
            Rational lowerbound = 0;
            Rational target = upperbound.Clone();
            for (long i = 0; i < precision * 5; i++)
            {
                Rational error = (upperbound - lowerbound) / 2;
                Rational guess = lowerbound + error;
                Rational bound = guess.Clone();
                for (int j = 1; j < flippedtarget; j++)
                {
                    guess *= bound;
                }
                if (guess > target)
                {
                    upperbound = bound;
                }
                if (guess < target)
                {
                    lowerbound = bound;
                }

            }
            for (int i = 0; i < funkyexponentiation; i++)
            {
                result *= lowerbound;
            }
            return result;
        }
コード例 #18
0
ファイル: Rational.cs プロジェクト: andykorth/MWGJ15
 public static Rational operator +(Rational c1, Rational c2)
 {
     int newDenom = lcm (c1.d, c2.d);
     int n1 = c1.n * newDenom / c1.d;
     int n2 = c2.n * newDenom / c2.d;
     Rational r = new Rational (n1 + n2, newDenom);
     r.Reduce ();
     return r;
 }
コード例 #19
0
 public RendererConfiguration(int backBufferWidth, int backBufferHeight, Format backBufferFormat,
     Rational refreshRate, bool windowed)
 {
     BackBufferWidth = backBufferWidth;
     BackBufferHeight = backBufferHeight;
     BackBufferFormat = backBufferFormat;
     RefreshRate = refreshRate;
     Windowed = windowed;
 }
コード例 #20
0
ファイル: ModeDescription.cs プロジェクト: alexey-bez/SharpDX
 /// <summary>
 ///   Initializes a new instance of the <see cref = "T:SharpDX.DXGI.ModeDescription" /> structure.
 /// </summary>
 /// <param name = "width">The width.</param>
 /// <param name = "height">The height.</param>
 /// <param name = "refreshRate">The refresh rate.</param>
 /// <param name = "format">The format.</param>
 public ModeDescription(int width, int height, Rational refreshRate, Format format)
 {
     this.Width = width;
     this.Height = height;
     this.RefreshRate = refreshRate;
     this.Format = format;
     this.ScanlineOrdering = DisplayModeScanlineOrder.Unspecified;
     this.Scaling = DisplayModeScaling.Unspecified;
 }
コード例 #21
0
 /// <summary>
 /// Creates array of rationals from array of integers
 /// </summary>
 /// <param name="values"></param>
 /// <returns></returns>
 public static Rational<long, Int64Policy>[] Create(long[] values)
 {
     var result = new Rational<long, Int64Policy>[values.Length];
     for(var i = 0; i < values.Length; i++)
     {
         result[i] = new Rational<long, Int64Policy>(values[i]);
     }
     return result;
 }
コード例 #22
0
ファイル: Program.cs プロジェクト: jschlitz/SupportVec2
 private static bool[] Classify(SVInfo[] sVecs, Datum[] testData, Func<Rational[], Rational[], Rational> kernel, Rational w0)
 {
     var foo = testData
     .Select(d => {
       var tmp = sVecs.Select(sv => sv.alpha * sv.y * kernel(sv.x, d.x)).Aggregate((acc, r) => acc + r) + w0;
       return tmp * d.y > 0;//numeric instability mignt make tmp not qute be -1/+1.
     })
     .ToArray();
       return foo;
 }
コード例 #23
0
ファイル: SmackerVideoTrack.cs プロジェクト: scemino/nscumm
 public SmackerVideoTrack(uint width, uint height, uint frameCount, Rational frameRate, uint flags, uint signature)
 {
     _surface = new Surface((int)width, (int)(height * (flags != 0 ? 2 : 1)), PixelFormat.Indexed8, false);
     _frameCount = frameCount;
     _frameRate = frameRate;
     _flags = flags;
     _signature = signature;
     _curFrame = -1;
     _dirtyPalette = false;
     _palette = new byte[3 * 256];
 }
コード例 #24
0
ファイル: RationalTest.cs プロジェクト: rettour/Labs
 public void EqualsTest()
 {
     Rational x = null;
     Rational y = new Rational(1, 2);
     Assert.IsFalse(x == y);
     Assert.IsTrue(new Rational(1, 2) == new Rational(1, 2));
     Assert.IsFalse(new Rational(1, 3) == new Rational(1, 2));
     Assert.IsFalse(new Rational(1, 2) != new Rational(1, 2));
     Assert.IsTrue(new Rational(1, 3) != new Rational(1, 2));
     Assert.IsFalse(new Rational(1, 3).Equals(new DateTime()));
 }
コード例 #25
0
ファイル: Utils.cs プロジェクト: perillaseed/z3
 /// <summary>
 /// Returns the Z3 term corresponding to the MSF rational number.
 /// </summary>
 /// <param name="rational">The MSF rational</param>
 /// <returns>The Z3 term</returns>
 public static ArithExpr GetNumeral(Context context, Rational rational, Sort sort = null)
 {
     try
     {
         sort = rational.IsInteger() ? ((Sort)context.IntSort) : (sort == null ? (Sort)context.RealSort : sort);
         return (ArithExpr)context.MkNumeral(rational.ToString(), sort);                
     }
     catch (Z3Exception e)
     {
         Console.Error.WriteLine("Conversion of {0} failed:\n {1}", rational, e);
         throw new NotSupportedException();
     }
 }
コード例 #26
0
        public void TestProperties_SettingGetting_Passed()
        {
            var rat = new Rational(10, 4);

            Assert.AreEqual(10, rat.Numerator);
            Assert.AreEqual(4, rat.Denominator);

            rat.Denominator = -13;
            Assert.AreEqual(-13, rat.Denominator);

            rat.Numerator = 0;
            Assert.AreEqual(0, rat.Numerator);
        }
コード例 #27
0
ファイル: StructFldAddr.cs プロジェクト: l1183479157/coreclr
 public static int Main()
 {
     Rational a = new Rational();
     Rational b = new Rational();
     a.num = 3;
     a.den = 4;
     b.num = 2;
     b.den = 3;
     RationalPolynomial rp = new RationalPolynomial();
     rp.a = a;
     rp.b = b;
     int y = StructFldAddr(rp);
     if (y == 5) return Pass;
     else return Fail;
 }
コード例 #28
0
ファイル: PiSymbol.cs プロジェクト: samphippen/precmaths
        private Rational PiSeries(int Precision)
        {
            Rational pi = 0;
            int moreprecision = Precision;
            Rational sixteentothek = new Rational(1);
            for (int i = 0; i < moreprecision; i++)
            {
                Rational a = new Rational(-2, 8 * i + 4);
                Rational b = new Rational(-1, 8 * i + 5);
                Rational c = new Rational(-1, 8 * i + 6);
                Rational d = new Rational(4, 8 * i + 1);
                pi += sixteentothek * (a + b + c + d);
                sixteentothek /= 16;
            }

            return pi;
        }
コード例 #29
0
        public string EvaluateString(int Precision)
        {
            foreach (Symbol s in this.symbollist){
                if (s is NumberSymbol)
                {
                    this.calculationstack.Push(s);
                }
                if (s is OperatorSymbol)
                {
                    NumberSymbol b = (NumberSymbol)this.calculationstack.Pop();
                    NumberSymbol a = (NumberSymbol)this.calculationstack.Pop();
                    OperatorSymbol so = (OperatorSymbol)s;
                    Rational result = new Rational(1);
                    if (so.ContainedOperator == MathOperator.Plus){
                        result = a.EvaluateRational(2 * Precision) + b.EvaluateRational(2 * Precision);
                    }
                    else if (so.ContainedOperator == MathOperator.Minus)
                    {
                        result = a.EvaluateRational(2 * Precision) - b.EvaluateRational(2 * Precision);
                    }
                    else if (so.ContainedOperator == MathOperator.Multiply)
                    {
                        result = a.EvaluateRational(2 * Precision) * b.EvaluateRational(2 * Precision);
                    }
                    else if (so.ContainedOperator == MathOperator.Divide)
                    {
                        result = a.EvaluateRational(2 * Precision) / b.EvaluateRational(2 * Precision);
                    }
                    else if (so.ContainedOperator == MathOperator.Power)
                    {
                        a.power *= b.EvaluateRational(Precision * 2);
                        result = a.EvaluateRational(Precision * 2);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                    this.calculationstack.Push(new RationalSymbol(result,1));
                }
            }

            NumberSymbol epic = (NumberSymbol)this.calculationstack.Pop();
            return epic.EvaluateRational(2 * Precision).EvaluateString(Precision);
        }
コード例 #30
0
ファイル: RationalTests.cs プロジェクト: dlemstra/Magick.NET
    public void Test_IEquatable()
    {
      Rational first = new Rational(3, 2);

      Assert.IsFalse(first.Equals(null));
      Assert.IsTrue(first.Equals(first));
      Assert.IsTrue(first.Equals((object)first));

      Rational second = new Rational(3, 2);

      Assert.IsTrue(first == second);
      Assert.IsTrue(first.Equals(second));
      Assert.IsTrue(first.Equals((object)second));

      second = new Rational(2, 3);

      Assert.IsTrue(first != second);
      Assert.IsFalse(first.Equals(second));
    }
コード例 #31
0
 private GraceNumber(double val)
     : base(createSharedMethods())
 {
     Value = Rational.Create(val);
 }
コード例 #32
0
        public void SetValue()
        {
            Rational[] latitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) };

            Image image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateImage();

            image.MetaData.ExifProfile.SetValue(ExifTag.Software, "ImageSharp");

            ExifValue value = image.MetaData.ExifProfile.GetValue(ExifTag.Software);

            TestValue(value, "ImageSharp");

            Assert.Throws <ArgumentException>(() => { value.Value = 15; });

            image.MetaData.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55));

            value = image.MetaData.ExifProfile.GetValue(ExifTag.ShutterSpeedValue);

            TestValue(value, new SignedRational(7555, 100));

            Assert.Throws <ArgumentException>(() => { value.Value = 75; });

            image.MetaData.ExifProfile.SetValue(ExifTag.XResolution, new Rational(150.0));

            // We also need to change this value because this overrides XResolution when the image is written.
            image.MetaData.HorizontalResolution = 150.0;

            value = image.MetaData.ExifProfile.GetValue(ExifTag.XResolution);
            TestValue(value, new Rational(150, 1));

            Assert.Throws <ArgumentException>(() => { value.Value = "ImageSharp"; });

            image.MetaData.ExifProfile.SetValue(ExifTag.ReferenceBlackWhite, null);

            value = image.MetaData.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite);
            TestValue(value, (string)null);

            image.MetaData.ExifProfile.SetValue(ExifTag.GPSLatitude, latitude);

            value = image.MetaData.ExifProfile.GetValue(ExifTag.GPSLatitude);
            TestValue(value, latitude);

            image = WriteAndRead(image);

            Assert.NotNull(image.MetaData.ExifProfile);
            Assert.Equal(17, image.MetaData.ExifProfile.Values.Count());

            value = image.MetaData.ExifProfile.GetValue(ExifTag.Software);
            TestValue(value, "ImageSharp");

            value = image.MetaData.ExifProfile.GetValue(ExifTag.ShutterSpeedValue);
            TestValue(value, new SignedRational(75.55));

            value = image.MetaData.ExifProfile.GetValue(ExifTag.XResolution);
            TestValue(value, new Rational(150.0));

            value = image.MetaData.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite);
            Assert.Null(value);

            value = image.MetaData.ExifProfile.GetValue(ExifTag.GPSLatitude);
            TestValue(value, latitude);

            image.MetaData.ExifProfile.Parts = ExifParts.ExifTags;

            image = WriteAndRead(image);

            Assert.NotNull(image.MetaData.ExifProfile);
            Assert.Equal(8, image.MetaData.ExifProfile.Values.Count());

            Assert.NotNull(image.MetaData.ExifProfile.GetValue(ExifTag.ColorSpace));
            Assert.True(image.MetaData.ExifProfile.RemoveValue(ExifTag.ColorSpace));
            Assert.False(image.MetaData.ExifProfile.RemoveValue(ExifTag.ColorSpace));
            Assert.Null(image.MetaData.ExifProfile.GetValue(ExifTag.ColorSpace));

            Assert.Equal(7, image.MetaData.ExifProfile.Values.Count());
        }
コード例 #33
0
ファイル: RadicalSumRatio.cs プロジェクト: erjicles/Radicals
 public RadicalSumRatio(Rational radicand)
     : this(new RadicalSum(radicand), RadicalSum.One)
 {
 }
コード例 #34
0
 public LinearEqualityRedundancy(Variable v1, Rational coeff2, Variable v2, Rational offset)
     : this(v1, coeff2, v2, offset, -23456)
 {
 }
コード例 #35
0
        public void SetValue(TestImageWriteFormat imageFormat)
        {
            Image <Rgba32> image = TestFile.Create(TestImages.Jpeg.Baseline.Floorplan).CreateRgba32Image();

            image.Metadata.ExifProfile.SetValue(ExifTag.Software, "ImageSharp");

            IExifValue <string> software = image.Metadata.ExifProfile.GetValue(ExifTag.Software);

            Assert.Equal("ImageSharp", software.Value);

            // ExifString can set integer values.
            Assert.True(software.TrySetValue(15));
            Assert.False(software.TrySetValue(15F));

            image.Metadata.ExifProfile.SetValue(ExifTag.ShutterSpeedValue, new SignedRational(75.55));

            IExifValue <SignedRational> shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue);

            Assert.Equal(new SignedRational(7555, 100), shutterSpeed.Value);
            Assert.False(shutterSpeed.TrySetValue(75));

            image.Metadata.ExifProfile.SetValue(ExifTag.XResolution, new Rational(150.0));

            // We also need to change this value because this overrides XResolution when the image is written.
            image.Metadata.HorizontalResolution = 150.0;

            IExifValue <Rational> xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution);

            Assert.Equal(new Rational(150, 1), xResolution.Value);

            Assert.False(xResolution.TrySetValue("ImageSharp"));

            image.Metadata.ExifProfile.SetValue(ExifTag.ReferenceBlackWhite, null);

            IExifValue <Rational[]> referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite);

            Assert.Null(referenceBlackWhite.Value);

            var expectedLatitude = new Rational[] { new Rational(12.3), new Rational(4.56), new Rational(789.0) };

            image.Metadata.ExifProfile.SetValue(ExifTag.GPSLatitude, expectedLatitude);

            IExifValue <Rational[]> latitude = image.Metadata.ExifProfile.GetValue(ExifTag.GPSLatitude);

            Assert.Equal(expectedLatitude, latitude.Value);

            int profileCount = image.Metadata.ExifProfile.Values.Count;

            image = WriteAndRead(image, imageFormat);

            Assert.NotNull(image.Metadata.ExifProfile);

            // Should be 3 less.
            // 1 x due to setting of null "ReferenceBlackWhite" value.
            // 2 x due to use of non-standard padding tag 0xEA1C listed in EXIF Tool. We can read those values but adhere
            // strictly to the 2.3.1 specification when writing. (TODO: Support 2.3.2)
            // https://exiftool.org/TagNames/EXIF.html
            Assert.Equal(profileCount - 3, image.Metadata.ExifProfile.Values.Count);

            software = image.Metadata.ExifProfile.GetValue(ExifTag.Software);
            Assert.Equal("15", software.Value);

            shutterSpeed = image.Metadata.ExifProfile.GetValue(ExifTag.ShutterSpeedValue);
            Assert.Equal(new SignedRational(75.55), shutterSpeed.Value);

            xResolution = image.Metadata.ExifProfile.GetValue(ExifTag.XResolution);
            Assert.Equal(new Rational(150.0), xResolution.Value);

            referenceBlackWhite = image.Metadata.ExifProfile.GetValue(ExifTag.ReferenceBlackWhite);
            Assert.Null(referenceBlackWhite);

            latitude = image.Metadata.ExifProfile.GetValue(ExifTag.GPSLatitude);
            Assert.Equal(expectedLatitude, latitude.Value);

            image.Metadata.ExifProfile.Parts = ExifParts.ExifTags;

            image = WriteAndRead(image, imageFormat);

            Assert.NotNull(image.Metadata.ExifProfile);
            Assert.Equal(8, image.Metadata.ExifProfile.Values.Count);

            Assert.NotNull(image.Metadata.ExifProfile.GetValue(ExifTag.ColorSpace));
            Assert.True(image.Metadata.ExifProfile.RemoveValue(ExifTag.ColorSpace));
            Assert.False(image.Metadata.ExifProfile.RemoveValue(ExifTag.ColorSpace));
            Assert.Null(image.Metadata.ExifProfile.GetValue(ExifTag.ColorSpace));

            Assert.Equal(7, image.Metadata.ExifProfile.Values.Count);
        }
コード例 #36
0
 public OctagonConstraintMinusXMinusY(int x, int y, Rational c)
 {
     this.x = x;
     this.y = y;
     this.c = c;
 }
コード例 #37
0
        public static void PrintProbabilityToOdds(Rational probability)
        {
            var odds = (int)Math.Round(1 / (double)probability, 2);

            Console.WriteLine($"1 : {odds.ToString("N1", CultureInfo.InvariantCulture)}");
        }
コード例 #38
0
 private static void _print(Rational number)
 {
     System.Console.WriteLine($"{number.numarator}/{number.numitor}");
 }
コード例 #39
0
        public static bool logic_operators(string semnul_logic, Rational a, Rational b)
        {
            bool result = false;

            switch (semnul_logic)
            {
            case "=":
            {
                if (a.numarator == b.numarator && a.numitor == b.numitor)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case ">":
            {
                if (a.numarator > b.numarator && a.numitor == b.numitor)
                {
                    return(true);
                }
                else if (a.numitor < b.numitor)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "<":
            {
                if (a.numarator < b.numarator && a.numitor == b.numitor)
                {
                    return(true);
                }
                else if (a.numitor > b.numitor)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "!=":
            {
                if (a.numarator != b.numarator || a.numitor != b.numitor)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case "<=":
            {
                if (a.numarator <= b.numarator && a.numitor == b.numitor)
                {
                    return(true);
                }
                else if (a.numitor >= b.numitor)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            case ">=":
            {
                if (a.numarator >= b.numarator && a.numitor == b.numitor)
                {
                    return(true);
                }
                else if (a.numitor <= b.numitor)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            }
            return(result);
        }
コード例 #40
0
 public void TestRational3() =>
 Assert.Equal(Rational.Create(15, 4),
              Rational.Create(7, 4) + Rational.Create(8, 4));
コード例 #41
0
 public void TestRational2() =>
 Assert.Equal(Rational.Create(7, 4), Rational.Create(3, 4) + 1);
コード例 #42
0
 public void TestRational1() =>
 Assert.Equal(Rational.Create(19, 12),
              Rational.Create(3, 4) + Rational.Create(5, 6));
コード例 #43
0
 public Vector3m Lerp(Vector3m a, Rational t)
 {
     return(this.Plus(a.Minus(this).Times(t)));
 }
コード例 #44
0
 public OctagonConstraintMinusXMinusY(int x, int y, Int32 c)
     : this(x, y, Rational.For(c))
 {
 }
コード例 #45
0
 public Vector3m(Rational x, Rational y, Rational z)
 {
     X = x;
     Y = y;
     Z = z;
 }
コード例 #46
0
 public OctagonConstraintMinusX(int x, Rational c)
 {
     this.x = x;
     this.y = -1;
     this.c = c;
 }
コード例 #47
0
 public void SetCutParam(Rational cut_param)
 {
     m_geom.cut_param = cut_param;
 }
コード例 #48
0
 public OctagonConstraintMinusX(int x, Int32 c)
     : this(x, Rational.For(c))
 {
 }
コード例 #49
0
        /// <exception cref="System.IO.IOException"/>
        private static void ProcessTag(TiffHandler handler, int tagId, int tagValueOffset, int componentCount, int formatCode, RandomAccessReader reader)
        {
            switch (formatCode)
            {
            case TiffDataFormat.CodeUndefined:
            {
                // this includes exif user comments
                handler.SetByteArray(tagId, reader.GetBytes(tagValueOffset, componentCount));
                break;
            }

            case TiffDataFormat.CodeString:
            {
                handler.SetString(tagId, reader.GetNullTerminatedString(tagValueOffset, componentCount));
                break;
            }

            case TiffDataFormat.CodeRationalS:
            {
                if (componentCount == 1)
                {
                    handler.SetRational(tagId, new Rational(reader.GetInt32(tagValueOffset), reader.GetInt32(tagValueOffset + 4)));
                }
                else
                {
                    if (componentCount > 1)
                    {
                        Rational[] array = new Rational[componentCount];
                        for (int i = 0; i < componentCount; i++)
                        {
                            array[i] = new Rational(reader.GetInt32(tagValueOffset + (8 * i)), reader.GetInt32(tagValueOffset + 4 + (8 * i)));
                        }
                        handler.SetRationalArray(tagId, array);
                    }
                }
                break;
            }

            case TiffDataFormat.CodeRationalU:
            {
                if (componentCount == 1)
                {
                    handler.SetRational(tagId, new Rational(reader.GetUInt32(tagValueOffset), reader.GetUInt32(tagValueOffset + 4)));
                }
                else
                {
                    if (componentCount > 1)
                    {
                        Rational[] array = new Rational[componentCount];
                        for (int i = 0; i < componentCount; i++)
                        {
                            array[i] = new Rational(reader.GetUInt32(tagValueOffset + (8 * i)), reader.GetUInt32(tagValueOffset + 4 + (8 * i)));
                        }
                        handler.SetRationalArray(tagId, array);
                    }
                }
                break;
            }

            case TiffDataFormat.CodeSingle:
            {
                if (componentCount == 1)
                {
                    handler.SetFloat(tagId, reader.GetFloat32(tagValueOffset));
                }
                else
                {
                    float[] array = new float[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetFloat32(tagValueOffset + (i * 4));
                    }
                    handler.SetFloatArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeDouble:
            {
                if (componentCount == 1)
                {
                    handler.SetDouble(tagId, reader.GetDouble64(tagValueOffset));
                }
                else
                {
                    double[] array = new double[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetDouble64(tagValueOffset + (i * 4));
                    }
                    handler.SetDoubleArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeInt8S:
            {
                if (componentCount == 1)
                {
                    handler.SetInt8s(tagId, reader.GetInt8(tagValueOffset));
                }
                else
                {
                    sbyte[] array = new sbyte[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetInt8(tagValueOffset + i);
                    }
                    handler.SetInt8sArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeInt8U:
            {
                if (componentCount == 1)
                {
                    handler.SetInt8u(tagId, reader.GetUInt8(tagValueOffset));
                }
                else
                {
                    short[] array = new short[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetUInt8(tagValueOffset + i);
                    }
                    handler.SetInt8uArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeInt16S:
            {
                if (componentCount == 1)
                {
                    handler.SetInt16s(tagId, (int)reader.GetInt16(tagValueOffset));
                }
                else
                {
                    short[] array = new short[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetInt16(tagValueOffset + (i * 2));
                    }
                    handler.SetInt16sArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeInt16U:
            {
                if (componentCount == 1)
                {
                    handler.SetInt16u(tagId, reader.GetUInt16(tagValueOffset));
                }
                else
                {
                    int[] array = new int[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetUInt16(tagValueOffset + (i * 2));
                    }
                    handler.SetInt16uArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeInt32S:
            {
                // NOTE 'long' in this case means 32 bit, not 64
                if (componentCount == 1)
                {
                    handler.SetInt32s(tagId, reader.GetInt32(tagValueOffset));
                }
                else
                {
                    int[] array = new int[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetInt32(tagValueOffset + (i * 4));
                    }
                    handler.SetInt32sArray(tagId, array);
                }
                break;
            }

            case TiffDataFormat.CodeInt32U:
            {
                // NOTE 'long' in this case means 32 bit, not 64
                if (componentCount == 1)
                {
                    handler.SetInt32u(tagId, reader.GetUInt32(tagValueOffset));
                }
                else
                {
                    long[] array = new long[componentCount];
                    for (int i = 0; i < componentCount; i++)
                    {
                        array[i] = reader.GetUInt32(tagValueOffset + (i * 4));
                    }
                    handler.SetInt32uArray(tagId, array);
                }
                break;
            }

            default:
            {
                handler.Error(Sharpen.Extensions.StringFormat("Unknown format code %d for tag %d", formatCode, tagId));
                break;
            }
            }
        }
コード例 #50
0
 static public OctagonConstraint For(int a, int x, Rational k)
 {
     return(OctagonConstraint.For(a, x, (Int32)k));
 }
コード例 #51
0
 private static void TestValue(ExifValue value, Rational expected)
 {
     Assert.NotNull(value);
     Assert.Equal(expected, value.Value);
 }
コード例 #52
0
        public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle)
        {
            try
            {
                #region Environment Configuration
                // Store the vsync setting.
                VerticalSyncEnabled = DSystemConfiguration.VerticalSyncEnabled;

                // Create a DirectX graphics interface factory.
                var factory = new Factory1();

                // Use the factory to create an adapter for the primary graphics interface (video card).
                var adapter = factory.GetAdapter1(0);

                // Get the primary adapter output (monitor).
                var monitor = adapter.GetOutput(0);

                // Get modes that fit the DXGI_FORMAT_R8G8B8A8_UNORM display format for the adapter output (monitor).
                var modes = monitor.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);

                // Now go through all the display modes and find the one that matches the screen width and height.
                // When a match is found store the the refresh rate for that monitor, if vertical sync is enabled.
                // Otherwise we use maximum refresh rate.
                var rational = new Rational(0, 1);
                if (VerticalSyncEnabled)
                {
                    foreach (var mode in modes)
                    {
                        if (mode.Width == configuration.Width && mode.Height == configuration.Height)
                        {
                            rational = new Rational(mode.RefreshRate.Numerator, mode.RefreshRate.Denominator);
                            break;
                        }
                    }
                }

                // Get the adapter (video card) description.
                var adapterDescription = adapter.Description;

                // Store the dedicated video card memory in megabytes.
                VideoCardMemory = adapterDescription.DedicatedVideoMemory >> 10 >> 10;

                // Convert the name of the video card to a character array and store it.
                VideoCardDescription = adapterDescription.Description.Trim('\0');

                // Release the adapter output.
                monitor.Dispose();
                // Release the adapter.
                adapter.Dispose();
                // Release the factory.
                factory.Dispose();
                #endregion

                #region Initialize swap chain and d3d device
                // Initialize the swap chain description.
                var swapChainDesc = new SwapChainDescription()
                {
                    // Set to a single back buffer.
                    BufferCount = 1,
                    // Set the width and height of the back buffer.
                    ModeDescription = new ModeDescription(configuration.Width, configuration.Height, rational, Format.R8G8B8A8_UNorm)
                    {
                        Scaling = DisplayModeScaling.Unspecified, ScanlineOrdering = DisplayModeScanlineOrder.Unspecified
                    },
                    // Set the usage of the back buffer.
                    Usage = Usage.RenderTargetOutput,
                    // Set the handle for the window to render to.
                    OutputHandle = windowHandle,
                    // Turn multisampling off.
                    SampleDescription = new SampleDescription(1, 0),
                    // Set to full screen or windowed mode.
                    IsWindowed = !DSystemConfiguration.FullScreen,
                    // Don't set the advanced flags.
                    Flags = SwapChainFlags.None,
                    // Discard the back buffer content after presenting.
                    SwapEffect = SwapEffect.Discard
                };

                // Create the swap chain, Direct3D device, and Direct3D device context.
                SharpDX.Direct3D11.Device device;
                SwapChain swapChain;
                SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, swapChainDesc, out device, out swapChain);

                Device        = device;
                SwapChain     = swapChain;
                DeviceContext = device.ImmediateContext;
                #endregion

                #region Initialize buffers
                // Get the pointer to the back buffer.
                var backBuffer = Texture2D.FromSwapChain <Texture2D>(SwapChain, 0);

                // Create the render target view with the back buffer pointer.
                RenderTargetView = new RenderTargetView(device, backBuffer);

                // Release pointer to the back buffer as we no longer need it.
                backBuffer.Dispose();

                // Initialize and set up the description of the depth buffer.
                var depthBufferDesc = new Texture2DDescription()
                {
                    Width             = configuration.Width,
                    Height            = configuration.Height,
                    MipLevels         = 1,
                    ArraySize         = 1,
                    Format            = Format.D24_UNorm_S8_UInt,
                    SampleDescription = new SampleDescription(1, 0),
                    Usage             = ResourceUsage.Default,
                    BindFlags         = BindFlags.DepthStencil,
                    CpuAccessFlags    = CpuAccessFlags.None,
                    OptionFlags       = ResourceOptionFlags.None
                };

                // Create the texture for the depth buffer using the filled out description.
                DepthStencilBuffer = new Texture2D(device, depthBufferDesc);
                #endregion

                #region Initialize Depth Enabled Stencil
                // Initialize and set up the description of the stencil state.
                var depthStencilDesc = new DepthStencilStateDescription()
                {
                    IsDepthEnabled   = true,
                    DepthWriteMask   = DepthWriteMask.All,
                    DepthComparison  = Comparison.Less,
                    IsStencilEnabled = true,
                    StencilReadMask  = 0xFF,
                    StencilWriteMask = 0xFF,
                    // Stencil operation if pixel front-facing.
                    FrontFace = new DepthStencilOperationDescription()
                    {
                        FailOperation      = StencilOperation.Keep,
                        DepthFailOperation = StencilOperation.Increment,
                        PassOperation      = StencilOperation.Keep,
                        Comparison         = Comparison.Always
                    },
                    // Stencil operation if pixel is back-facing.
                    BackFace = new DepthStencilOperationDescription()
                    {
                        FailOperation      = StencilOperation.Keep,
                        DepthFailOperation = StencilOperation.Decrement,
                        PassOperation      = StencilOperation.Keep,
                        Comparison         = Comparison.Always
                    }
                };

                // Create the depth stencil state.
                DepthStencilState = new DepthStencilState(Device, depthStencilDesc);
                #endregion

                #region Initialize Output Merger
                // Set the depth stencil state.
                DeviceContext.OutputMerger.SetDepthStencilState(DepthStencilState, 1);

                // Initialize and set up the depth stencil view.
                var depthStencilViewDesc = new DepthStencilViewDescription()
                {
                    Format    = Format.D24_UNorm_S8_UInt,
                    Dimension = DepthStencilViewDimension.Texture2D,
                    Texture2D = new DepthStencilViewDescription.Texture2DResource()
                    {
                        MipSlice = 0
                    }
                };

                // Create the depth stencil view.
                DepthStencilView = new DepthStencilView(Device, DepthStencilBuffer, depthStencilViewDesc);

                // Bind the render target view and depth stencil buffer to the output render pipeline.
                DeviceContext.OutputMerger.SetTargets(DepthStencilView, RenderTargetView);
                #endregion

                #region Initialize Raster State
                // Setup the raster description which will determine how and what polygon will be drawn.
                var rasterDesc = new RasterizerStateDescription()
                {
                    IsAntialiasedLineEnabled = false,
                    CullMode                = CullMode.Back,
                    DepthBias               = 0,
                    DepthBiasClamp          = .0f,
                    IsDepthClipEnabled      = true,
                    FillMode                = FillMode.Solid,
                    IsFrontCounterClockwise = false,
                    IsMultisampleEnabled    = false,
                    IsScissorEnabled        = false,
                    SlopeScaledDepthBias    = .0f
                };

                // Create the rasterizer state from the description we just filled out.
                RasterState = new RasterizerState(Device, rasterDesc);
                #endregion

                #region Initialize Rasterizer
                // Now set the rasterizer state.
                DeviceContext.Rasterizer.State = RasterState;

                ViewPort = new ViewportF(0.0f, 0.0f, (float)configuration.Width, (float)configuration.Height, 0.0f, 1.0f);

                // Setup and create the viewport for rendering.
                DeviceContext.Rasterizer.SetViewport(ViewPort);
                #endregion

                #region Initialize matrices
                // Setup and create the projection matrix.
                ProjectionMatrix = Matrix.PerspectiveFovLH((float)(Math.PI / 4), ((float)configuration.Width / (float)configuration.Height), DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth);

                // Initialize the world matrix to the identity matrix.
                WorldMatrix = Matrix.Identity;

                // Create an orthographic projection matrix for 2D rendering.
                OrthoMatrix = Matrix.OrthoLH(configuration.Width, configuration.Height, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth);
                #endregion

                #region Initialize Depth Disabled Stencil
                // Now create a second depth stencil state which turns off the Z buffer for 2D rendering. Added in Tutorial 11
                // The difference is that DepthEnable is set to false.
                // All other parameters are the same as the other depth stencil state.
                var depthDisabledStencilDesc = new DepthStencilStateDescription()
                {
                    IsDepthEnabled   = false,
                    DepthWriteMask   = DepthWriteMask.All,
                    DepthComparison  = Comparison.Less,
                    IsStencilEnabled = true,
                    StencilReadMask  = 0xFF,
                    StencilWriteMask = 0xFF,
                    // Stencil operation if pixel front-facing.
                    FrontFace = new DepthStencilOperationDescription()
                    {
                        FailOperation      = StencilOperation.Keep,
                        DepthFailOperation = StencilOperation.Increment,
                        PassOperation      = StencilOperation.Keep,
                        Comparison         = Comparison.Always
                    },
                    // Stencil operation if pixel is back-facing.
                    BackFace = new DepthStencilOperationDescription()
                    {
                        FailOperation      = StencilOperation.Keep,
                        DepthFailOperation = StencilOperation.Decrement,
                        PassOperation      = StencilOperation.Keep,
                        Comparison         = Comparison.Always
                    }
                };

                // Create the depth stencil state.
                DepthDisabledStencilState = new DepthStencilState(Device, depthDisabledStencilDesc);
                #endregion

                #region Initialize Blend States
                // Create an alpha enabled blend state description.
                var blendStateDesc = new BlendStateDescription();
                blendStateDesc.RenderTarget[0].IsBlendEnabled        = true;
                blendStateDesc.RenderTarget[0].SourceBlend           = BlendOption.SourceAlpha;
                blendStateDesc.RenderTarget[0].DestinationBlend      = BlendOption.InverseSourceAlpha;
                blendStateDesc.RenderTarget[0].BlendOperation        = BlendOperation.Add;
                blendStateDesc.RenderTarget[0].SourceAlphaBlend      = BlendOption.One;
                blendStateDesc.RenderTarget[0].DestinationAlphaBlend = BlendOption.Zero;
                blendStateDesc.RenderTarget[0].AlphaBlendOperation   = BlendOperation.Add;
                blendStateDesc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;

                // Create the blend state using the description.
                AlphaEnableBlendingState = new BlendState(device, blendStateDesc);

                // Modify the description to create an disabled blend state description.
                blendStateDesc.RenderTarget[0].IsBlendEnabled = false;

                // Create the blend state using the description.
                AlphaDisableBlendingState = new BlendState(device, blendStateDesc);
                #endregion

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #53
0
ファイル: RadicalSumRatio.cs プロジェクト: erjicles/Radicals
 public RadicalSumRatio(Rational coefficient, BigInteger radicand)
     : this(new RadicalSum(coefficient, radicand))
 {
 }
コード例 #54
0
 public Vector3m DividedBy(Rational a)
 {
     return(new Vector3m(this.X / a, this.Y / a, this.Z / a));
 }
コード例 #55
0
        internal static string GetPropertyValue(PropertyItem[] Items, int siID)
        {
            Encoding     soAscii = Encoding.ASCII;
            string       ssValue = "";
            PropertyItem soItem  = GetPropertyItem(Items, siID);

            if (soItem != null)
            {
                if (soItem.Value != null)
                {
                    //1 = BYTE An 8-bit unsigned integer.,
                    if (soItem.Type == 0x1)
                    {
                        switch (soItem.Id)
                        {
                        case 0:
                            ssValue = soItem.Value[0].ToString();
                            for (int i = 1; i < soItem.Value.Length; i++)
                            {
                                ssValue += "." + soItem.Value[i].ToString();
                            }
                            break;

                        default:
                            ssValue = soItem.Value[0].ToString();
                            break;
                        }
                    }
                    //2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.,
                    else if (soItem.Type == 0x2)
                    {
                        // string
                        ssValue = soAscii.GetString(soItem.Value);
                    }
                    //3 = SHORT A 16-bit (2 -byte) unsigned integer,
                    else if (soItem.Type == 0x3)
                    {
                        // orientation // lookup table
                        switch (soItem.Id)
                        {
                        case 0x8827:     // ISO
                            ssValue = convertToInt16U(soItem.Value).ToString();
                            break;

                        case 0xA217:     // sensing method
                        {
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 1: ssValue = Properties.Resources.SensingMethod1; break;

                            case 2: ssValue = Properties.Resources.SensingMethod2; break;

                            case 3: ssValue = Properties.Resources.SensingMethod3; break;

                            case 4: ssValue = Properties.Resources.SensingMethod4; break;

                            case 5: ssValue = Properties.Resources.SensingMethod5; break;

                            case 7: ssValue = Properties.Resources.SensingMethod7; break;

                            case 8: ssValue = Properties.Resources.SensingMethod8; break;

                            default: ssValue = Properties.Resources.SensingMethodDefault; break;
                            }
                        }
                        break;

                        case 0x112:     // Orientation
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 1: ssValue = Properties.Resources.Orientation1; break;

                            case 2: ssValue = Properties.Resources.Orientation2; break;

                            case 3: ssValue = Properties.Resources.Orientation3; break;

                            case 4: ssValue = Properties.Resources.Orientation4; break;

                            case 5: ssValue = Properties.Resources.Orientation5; break;

                            case 6: ssValue = Properties.Resources.Orientation6; break;

                            case 7: ssValue = Properties.Resources.Orientation7; break;

                            case 8: ssValue = Properties.Resources.Orientation8; break;

                            default: ssValue = Properties.Resources.OrientationDefault; break;
                            }
                            break;

                        case 0x8822:     // aperture
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.Aperture0; break;

                            case 1: ssValue = Properties.Resources.Aperture1; break;

                            case 2: ssValue = Properties.Resources.Aperture2; break;

                            case 3: ssValue = Properties.Resources.Aperture3; break;

                            case 4: ssValue = Properties.Resources.Aperture4; break;

                            case 5: ssValue = Properties.Resources.Aperture5; break;

                            case 6: ssValue = Properties.Resources.Aperture6; break;

                            case 7: ssValue = Properties.Resources.Aperture7; break;

                            case 8: ssValue = Properties.Resources.Aperture8; break;

                            default: ssValue = Properties.Resources.ApertureDefault; break;
                            }
                            break;

                        case 0x9207:     // metering mode
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.MeteringMode0; break;

                            case 1: ssValue = Properties.Resources.MeteringMode1; break;

                            case 2: ssValue = Properties.Resources.MeteringMode2; break;

                            case 3: ssValue = Properties.Resources.MeteringMode3; break;

                            case 4: ssValue = Properties.Resources.MeteringMode4; break;

                            case 5: ssValue = Properties.Resources.MeteringMode5; break;

                            case 6: ssValue = Properties.Resources.MeteringMode6; break;

                            case 255: ssValue = Properties.Resources.MeteringMode255; break;

                            default: ssValue = Properties.Resources.MeteringModeDefault; break;
                            }
                            break;

                        case 0x9208:     // light source
                        {
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.LightSource0; break;

                            case 1: ssValue = Properties.Resources.LightSource1; break;

                            case 2: ssValue = Properties.Resources.LightSource2; break;

                            case 3: ssValue = Properties.Resources.LightSource3; break;

                            case 4: ssValue = Properties.Resources.LightSource4; break;

                            case 9: ssValue = Properties.Resources.LightSource9; break;

                            case 10: ssValue = Properties.Resources.LightSource10; break;

                            case 11: ssValue = Properties.Resources.LightSource11; break;

                            case 12: ssValue = Properties.Resources.LightSource12; break;

                            case 13: ssValue = Properties.Resources.LightSource13; break;

                            case 14: ssValue = Properties.Resources.LightSource14; break;

                            case 15: ssValue = Properties.Resources.LightSource15; break;

                            case 17: ssValue = Properties.Resources.LightSource17; break;

                            case 18: ssValue = Properties.Resources.LightSource18; break;

                            case 19: ssValue = Properties.Resources.LightSource19; break;

                            case 20: ssValue = Properties.Resources.LightSource20; break;

                            case 21: ssValue = Properties.Resources.LightSource21; break;

                            case 22: ssValue = Properties.Resources.LightSource22; break;

                            case 23: ssValue = Properties.Resources.LightSource23; break;

                            case 24: ssValue = Properties.Resources.LightSource24; break;

                            case 255: ssValue = Properties.Resources.LightSource255; break;

                            default: ssValue = Properties.Resources.LightSourceDefault; break;
                            }
                        }
                        break;

                        case 0x0128:     //ResolutionUnit
                        {
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 2: ssValue = Properties.Resources.ResolutionUnit2; break;

                            case 3: ssValue = Properties.Resources.ResolutionUnit3; break;

                            default: ssValue = Properties.Resources.ResolutionUnitDefault; break;
                            }
                        }
                        break;

                        //case 0x9209:
                        //    {
                        //        switch (convertToInt16U(soItem.Value))
                        //        {
                        //            case 0: ssValue = Properties.Resources.Flash0; break;
                        //            case 1: ssValue = Properties.Resources.Flash1; break;
                        //            case 5: ssValue = Properties.Resources.Flash3; break;
                        //            case 7: ssValue = Properties.Resources.Flash4; break;
                        //            default: ssValue = Properties.Resources.FlashDefault; break;
                        //        }
                        //    }
                        //break;
                        case 0xA402:     //ExposureMode
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.ExposureMode0; break;

                            case 1: ssValue = Properties.Resources.ExposureMode1; break;

                            case 2: ssValue = Properties.Resources.ExposureMode2; break;

                            default: ssValue = Properties.Resources.ExposureModeDefault; break;
                            }
                            break;

                        case 0xA401:     //CustomRendered
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.CustomRendered0; break;

                            case 1: ssValue = Properties.Resources.CustomRendered1; break;

                            default: ssValue = Properties.Resources.CustomRenderedDefault; break;
                            }
                            break;

                        case 0xA403:     //WhiteBalance
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.WhiteBalance0; break;

                            case 1: ssValue = Properties.Resources.WhiteBalance1; break;

                            default: ssValue = Properties.Resources.WhiteBalanceDefault; break;
                            }
                            break;

                        case 0xA406:     //SceneCaptureType
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.SceneCaptureType0; break;

                            case 1: ssValue = Properties.Resources.SceneCaptureType1; break;

                            case 2: ssValue = Properties.Resources.SceneCaptureType2; break;

                            case 3: ssValue = Properties.Resources.SceneCaptureType3; break;

                            default: ssValue = Properties.Resources.SceneCaptureTypeDefault; break;
                            }
                            break;

                        case 0xA407:     //GainControl
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.GainControl0; break;

                            case 1: ssValue = Properties.Resources.GainControl1; break;

                            case 2: ssValue = Properties.Resources.GainControl2; break;

                            case 3: ssValue = Properties.Resources.GainControl3; break;

                            case 4: ssValue = Properties.Resources.GainControl4; break;

                            default: ssValue = Properties.Resources.GainControlDefault; break;
                            }
                            break;

                        case 0xA408:     //Contrast
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.Contrast0; break;

                            case 1: ssValue = Properties.Resources.Contrast1; break;

                            case 2: ssValue = Properties.Resources.Contrast2; break;

                            default: ssValue = Properties.Resources.ContrastDefault; break;
                            }
                            break;

                        case 0xA409:     //Saturation
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.Saturation0; break;

                            case 1: ssValue = Properties.Resources.Saturation1; break;

                            case 2: ssValue = Properties.Resources.Saturation2; break;

                            default: ssValue = Properties.Resources.SaturationDefault; break;
                            }
                            break;

                        case 0xA40A:     //Sharpness
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.Sharpness0; break;

                            case 1: ssValue = Properties.Resources.Sharpness1; break;

                            case 2: ssValue = Properties.Resources.Sharpness2; break;

                            default: ssValue = Properties.Resources.SharpnessDefault; break;
                            }
                            break;

                        case 0xA40C:     //SubjectDistanceRange
                            switch (convertToInt16U(soItem.Value))
                            {
                            case 0: ssValue = Properties.Resources.SubjectDistanceRange0; break;

                            case 1: ssValue = Properties.Resources.SubjectDistanceRange1; break;

                            case 2: ssValue = Properties.Resources.SubjectDistanceRange2; break;

                            case 3: ssValue = Properties.Resources.SubjectDistanceRange3; break;

                            default: ssValue = Properties.Resources.SubjectDistanceRangeDefault; break;
                            }
                            break;

                        default:
                            ssValue = convertToInt16U(soItem.Value).ToString();
                            break;
                        }
                    }
                    //4 = LONG A 32-bit (4 -byte) unsigned integer,
                    else if (soItem.Type == 0x4)
                    {
                        // orientation // lookup table
                        ssValue = convertToInt32U(soItem.Value).ToString();
                    }
                    //5 = RATIONAL Two LONGs. The first LONG is the numerator and the second LONG expresses the//denominator.,
                    else if (soItem.Type == 0x5)
                    {
                        URational r = new URational(soItem.Value);
                        //
                        //convert here
                        //
                        switch (soItem.Id)
                        {
                        case 0x9202:     // aperture
                            ssValue = "f " + Math.Round(Math.Pow(Math.Sqrt(2), r.ToDouble()), 2).ToString("0.00");
                            break;

                        case 0x920A:
                            ssValue = r.ToDouble().ToString();
                            break;

                        case 0x829A:
                            ssValue = r.ToString("/");
                            if (ssValue.IndexOf("/1") != -1)
                            {
                                ssValue = Convert.ToInt16(ssValue.Substring(0, ssValue.IndexOf("/1"))).ToString("0.0");
                            }
                            break;

                        case 0x829D:     // F-number
                            ssValue = "F/" + r.ToDouble().ToString();
                            break;

                        case 0xA20E:     // FocalPlaneXResolution
                            ssValue = Math.Round(r.ToDouble()).ToString();
                            break;

                        case 0xA20F:     // FocalPlaneYResolution
                            ssValue = Math.Round(r.ToDouble()).ToString();
                            break;

                        case 0x9205:     //MaxAparture
                            ssValue = r.ToDouble().ToString();
                            break;

                        case 0x2:     // GPSLatitude
                            ssValue = new GPSRational(soItem.Value).ToString();
                            break;

                        case 0x4:     // GPSLongitude
                            ssValue = new GPSRational(soItem.Value).ToString();
                            break;

                        case 0x7:     // GPSTimeStamp
                            ssValue = new GPSRational(soItem.Value).ToString(":");
                            break;

                        default:
                            ssValue = r.ToString("/");
                            break;
                        }
                    }
                    //7 = UNDEFINED An 8-bit byte that can take any value depending on the field definition,
                    else if (soItem.Type == 0x7)
                    {
                        switch (soItem.Id)
                        {
                        case 0xA300:
                        {
                            if (soItem.Value[0] == 3)
                            {
                                ssValue = Properties.Resources.ImageSource3;
                            }
                            else
                            {
                                ssValue = Properties.Resources.ImageSourceDefault;
                            }
                            break;
                        }

                        case 0xA301:
                            if (soItem.Value[0] == 1)
                            {
                                ssValue = Properties.Resources.SceneType1;
                            }
                            else
                            {
                                ssValue = Properties.Resources.SceneTypeDefault;
                            }
                            break;

                        case 0x9000:
                            if (soItem.Value != null)
                            {
                                ssValue = ((double)Convert.ToInt16(soAscii.GetString(soItem.Value)) / 100).ToString().Replace(",", ".");
                            }
                            break;

                        default:
                            if (soItem.Value != null)
                            {
                                ssValue = soAscii.GetString(soItem.Value);
                            }
                            break;
                        }
                    }
                    //9 = SLONG A 32-bit (4 -byte) signed integer (2's complement notation),
                    else if (soItem.Type == 0x9)
                    {
                        ssValue = convertToInt32(soItem.Value).ToString();
                    }
                    //10 = SRATIONAL Two SLONGs. The first SLONG is the numerator and the second SLONG is the denominator.
                    else if (soItem.Type == 0xA)
                    {
                        Rational r = new Rational(soItem.Value);
                        switch (soItem.Id)
                        {
                        case 0x9201:     // shutter speed
                            ssValue = "1/" + Math.Round(Math.Pow(2, r.ToDouble()), 2).ToString();
                            break;

                        case 0x9203:
                            ssValue = Math.Round(r.ToDouble(), 4).ToString();
                            break;

                        case 0x9204:
                            ssValue = Math.Round(r.ToDouble(), 4).ToString("0.00") + " EV";
                            break;

                        default:
                            ssValue = r.ToString("/");
                            break;
                        }
                    }
                }
            }
            return(ssValue);
        }
コード例 #56
0
 public Vector3m Times(Rational a)
 {
     return(new Vector3m(this.X * a, this.Y * a, this.Z * a));
 }
コード例 #57
0
 /// <summary>Make a Grace number</summary>
 /// <param name="val">Number to create</param>
 public static GraceObject Create(Rational val)
 {
     return(new GraceNumber(val));
 }
コード例 #58
0
 public void ImplizitNegated()
 {
     X = -X; Y = -Y; Z = -Z;
 }
コード例 #59
0
        /// <summary>
        ///
        /// </summary>
        private void buildDB(System.Drawing.Imaging.PropertyItem[] parr)
        {
            properties.Clear();
            //
            data = "";
            //
            Encoding ascii = Encoding.ASCII;

            //
            foreach (System.Drawing.Imaging.PropertyItem p in parr)
            {
                string v    = "";
                string name = (string)myHash[p.Id];
                // tag not found. skip it
                if (name == null)
                {
                    continue;
                }
                //
                data += name + ": ";
                //
                //1 = BYTE An 8-bit unsigned integer.,
                if (p.Type == 0x1)
                {
                    v = p.Value[0].ToString();
                }
                //2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL.,
                else if (p.Type == 0x2)
                {
                    // string
                    v = ascii.GetString(p.Value);
                }
                //3 = SHORT A 16-bit (2 -byte) unsigned integer,
                else if (p.Type == 0x3)
                {
                    // orientation // lookup table
                    switch (p.Id)
                    {
                    case 0x8827:     // ISO
                        v = "ISO-" + convertToInt16U(p.Value).ToString();
                        break;

                    case 0xA217:     // sensing method
                    {
                        switch (convertToInt16U(p.Value))
                        {
                        case 1: v = "Not defined"; break;

                        case 2: v = "One-chip color area sensor"; break;

                        case 3: v = "Two-chip color area sensor"; break;

                        case 4: v = "Three-chip color area sensor"; break;

                        case 5: v = "Color sequential area sensor"; break;

                        case 7: v = "Trilinear sensor"; break;

                        case 8: v = "Color sequential linear sensor"; break;

                        default: v = " reserved"; break;
                        }
                    }
                    break;

                    case 0x8822:     // aperture
                        switch (convertToInt16U(p.Value))
                        {
                        case 0: v = "Not defined"; break;

                        case 1: v = "Manual"; break;

                        case 2: v = "Normal program"; break;

                        case 3: v = "Aperture priority"; break;

                        case 4: v = "Shutter priority"; break;

                        case 5: v = "Creative program (biased toward depth of field)"; break;

                        case 6: v = "Action program (biased toward fast shutter speed)"; break;

                        case 7: v = "Portrait mode (for closeup photos with the background out of focus)"; break;

                        case 8: v = "Landscape mode (for landscape photos with the background in focus)"; break;

                        default: v = "reserved"; break;
                        }
                        break;

                    case 0x9207:     // metering mode
                        switch (convertToInt16U(p.Value))
                        {
                        case 0: v = "unknown"; break;

                        case 1: v = "Average"; break;

                        case 2: v = "CenterWeightedAverage"; break;

                        case 3: v = "Spot"; break;

                        case 4: v = "MultiSpot"; break;

                        case 5: v = "Pattern"; break;

                        case 6: v = "Partial"; break;

                        case 255: v = "Other"; break;

                        default: v = "reserved"; break;
                        }
                        break;

                    case 0x9208:     // light source
                    {
                        switch (convertToInt16U(p.Value))
                        {
                        case 0: v = "unknown"; break;

                        case 1: v = "Daylight"; break;

                        case 2: v = "Fluorescent"; break;

                        case 3: v = "Tungsten"; break;

                        case 17: v = "Standard light A"; break;

                        case 18: v = "Standard light B"; break;

                        case 19: v = "Standard light C"; break;

                        case 20: v = "D55"; break;

                        case 21: v = "D65"; break;

                        case 22: v = "D75"; break;

                        case 255: v = "other"; break;

                        default: v = "reserved"; break;
                        }
                    }
                    break;

                    case 0x9209:
                    {
                        switch (convertToInt16U(p.Value))
                        {
                        case 0: v = "Flash did not fire"; break;

                        case 1: v = "Flash fired"; break;

                        case 5: v = "Strobe return light not detected"; break;

                        case 7: v = "Strobe return light detected"; break;

                        default: v = "reserved"; break;
                        }
                    }
                    break;

                    default:
                        v = convertToInt16U(p.Value).ToString();
                        break;
                    }
                }
                //4 = LONG A 32-bit (4 -byte) unsigned integer,
                else if (p.Type == 0x4)
                {
                    // orientation // lookup table
                    v = convertToInt32U(p.Value).ToString();
                }
                //5 = RATIONAL Two LONGs. The first LONG is the numerator and the second LONG expresses the//denominator.,
                else if (p.Type == 0x5)
                {
                    // rational
                    byte[] n = new byte[p.Len / 2];
                    byte[] d = new byte[p.Len / 2];
                    Array.Copy(p.Value, 0, n, 0, p.Len / 2);
                    Array.Copy(p.Value, p.Len / 2, d, 0, p.Len / 2);
                    uint     a = convertToInt32U(n);
                    uint     b = convertToInt32U(d);
                    Rational r = new Rational(a, b);
                    //
                    //convert here
                    //
                    switch (p.Id)
                    {
                    case 0x9202:     // aperture
                        v = "F/" + Math.Round(Math.Pow(Math.Sqrt(2), r.ToDouble()), 2).ToString();
                        break;

                    case 0x920A:
                        v = r.ToDouble().ToString();
                        break;

                    case 0x829A:
                        v = r.ToDouble().ToString();
                        break;

                    case 0x829D:     // F-number
                        v = "F/" + r.ToDouble().ToString();
                        break;

                    default:
                        v = r.ToString("/");
                        break;
                    }
                }
                //7 = UNDEFINED An 8-bit byte that can take any value depending on the field definition,
                else if (p.Type == 0x7)
                {
                    switch (p.Id)
                    {
                    case 0xA300:
                    {
                        if (p.Value[0] == 3)
                        {
                            v = "DSC";
                        }
                        else
                        {
                            v = "reserved";
                        }
                        break;
                    }

                    case 0xA301:
                        if (p.Value[0] == 1)
                        {
                            v = "A directly photographed image";
                        }
                        else
                        {
                            v = "Not a directly photographed image";
                        }
                        break;

                    default:
                        v = "-";
                        break;
                    }
                }
                //9 = SLONG A 32-bit (4 -byte) signed integer (2´s complement notation),
                else if (p.Type == 0x9)
                {
                    v = convertToInt32(p.Value).ToString();
                }
                //10 = SRATIONAL Two SLONGs. The first SLONG is the numerator and the second SLONG is the
                //denominator.
                else if (p.Type == 0xA)
                {
                    // rational
                    byte[] n = new byte[p.Len / 2];
                    byte[] d = new byte[p.Len / 2];
                    Array.Copy(p.Value, 0, n, 0, p.Len / 2);
                    Array.Copy(p.Value, p.Len / 2, d, 0, p.Len / 2);
                    int      a = convertToInt32(n);
                    int      b = convertToInt32(d);
                    Rational r = new Rational(a, b);
                    //
                    // convert here
                    //
                    switch (p.Id)
                    {
                    case 0x9201:     // shutter speed
                        v = "1/" + Math.Round(Math.Pow(2, r.ToDouble()), 2).ToString();
                        break;

                    case 0x9203:
                        v = Math.Round(r.ToDouble(), 4).ToString();
                        break;

                    default:
                        v = r.ToString("/");
                        break;
                    }
                }
                // add it to the list
                if (properties[name] == null)
                {
                    properties.Add(name, v);
                }
                // cat it too
                data += v;
                data += this.sp;
            }
        }
コード例 #60
0
        /// <summary>
        /// Итерация метода ветвей и границ
        /// </summary>
        /// <param name="additionalRestrictions">Дополнительные ограничения, вводимые при ветвлении</param>
        private void Iterate(List <DataRow> additionalRestrictions)
        {
            DataTable dt = (dataGridView1.DataSource as DataTable).Copy();

            dt.Columns.RemoveAt(0);
            Dictionary <int, int> rSign   = new Dictionary <int, int>();
            StringBuilder         @string = new StringBuilder();

            foreach (var r in additionalRestrictions)
            {
                var x = dt.NewRow();
                x.ItemArray = r.ItemArray.Clone() as object[];
                for (int j = 0; j < r.ItemArray.Length; j++)
                {
                    if (!(x[j] is DBNull))
                    {
                        int sgn = Math.Sign(((Rational)x[j]).ToDouble());
                        if (sgn != 0 && j < x.ItemArray.Length - 1)
                        {
                            rSign.Add(dt.Rows.Count, sgn);
                            @string.AppendFormat(" x{0}{1}{2}", j + 1,
                                                 sgn > 0 ? '≤' : '≥',
                                                 Rational.Abs((Rational)x[x.ItemArray.Length - 1]));
                        }
                        x[j] = Rational.Abs((Rational)x[j]);
                    }
                }
                dt.Rows.Add(x);
            }

            int xcnt = dt.Columns.Count - 1;
            int scnt = dt.Rows.Count - 1;

            Rational[,] matrix = new Rational[xcnt + scnt + 2, scnt + 2];
            for (int j = 0; j < matrix.GetLength(0); j++) //Столбцы
            {
                matrix[j, 0] = j;
            }
            for (int i = 1; i < matrix.GetLength(1); i++) //Строки
            {
                matrix[0, i] = i == 1 ? 0 : i + xcnt - 1;
                for (int j = 1; j < matrix.GetLength(0); j++) //Столбцы
                {
                    if (j < dt.Columns.Count)                 //Заполним для всех Х
                    {
                        object txx = dt.Rows[i - 1][j - 1];
                        matrix[j, i] = txx is DBNull ? 0 : (Rational)txx;
                    }
                    else if (matrix[0, i] == matrix[j, 0]) //Для всех S единички по диагонали
                    {
                        matrix[j, i] = rSign.ContainsKey(i) ? rSign[i] : 1;
                    }
                    else if (j == matrix.GetLength(0) - 1)
                    {
                        object txx = dt.Rows[i - 1][dt.Columns.Count - 1];
                        matrix[j, i] = txx is DBNull ? 0 : (Rational)txx;
                    }
                    else
                    {
                        matrix[j, i] = 0;
                    }
                }
            }
            //PrintMatrix(matrix);
            textBox1.AppendText(string.Format("\r\nРешение{0}:{1}", @string.ToString(), Environment.NewLine));
            Simplex(matrix, checkBox1.Checked);
            Rational[] result = new Rational[xcnt];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = 0;
            }
            for (int i = 2; i < matrix.GetLength(1); i++)
            {
                if (matrix[0, i] <= xcnt)
                {
                    result[matrix[0, i].Numerator - 1] = matrix[matrix.GetLength(0) - 1, i];
                }
            }
            int rIdx = -1;

            for (int i = 0; i < result.Length; i++)
            {
                textBox1.AppendText(string.Format("x{0}={1}{2}", i + 1, result[i].ToMixedString(),
                                                  i != result.Length - 1 ? "; " : "  "));
                if (rIdx < 0 && result[i].Denominator > 1) //Дробный корень
                {
                    rIdx = i;
                }
            }
            textBox1.AppendText(string.Format("z(max)= {2}   {0} решение{1}", rIdx < 0 && matrix[matrix.GetLength(0) - 1, 1].Denominator == 1
                ? "Целое" : "Дробное", Environment.NewLine,
                                              matrix[matrix.GetLength(0) - 1, 1].ToMixedString()));
            if (rIdx < 0)
            {
                if (matrix[matrix.GetLength(0) - 1, 1].Denominator != 1)
                {
                    textBox1.AppendText("Нет решения" + Environment.NewLine);
                    return;
                }
                for (int i = 2; i < dataGridView1.RowCount; i++)
                {
                    Rational check = 0;
                    for (int j = 1; j < dataGridView1.Columns.Count - 1; j++)
                    {
                        check += (result[j - 1] * (Rational)(dataGridView1[j, i].Value is DBNull ?
                                                             Rational.Zero : dataGridView1[j, i].Value));
                    }
                    if (check > (Rational)dataGridView1[dataGridView1.ColumnCount - 1, i].Value)
                    {
                        textBox1.AppendText("Ограничения не выполнены" + Environment.NewLine);
                        return;
                    }
                }
                if (checkBox1.Checked == false)
                {
                    if (matrix[matrix.GetLength(0) - 1, 1] > record[record.Length - 1])
                    {
                        for (int i = 0; i < record.Length - 1; i++)
                        {
                            record[i] = result[i];
                        }
                        record[record.Length - 1] = matrix[matrix.GetLength(0) - 1, 1];
                    }
                }
                else
                {
                    if (matrix[matrix.GetLength(0) - 1, 1] < record[record.Length - 1] || record[record.Length - 1] == 0)
                    {
                        for (int i = 0; i < record.Length - 1; i++)
                        {
                            record[i] = result[i];
                        }
                        record[record.Length - 1] = matrix[matrix.GetLength(0) - 1, 1];
                    }
                }
            }
            if (rIdx >= 0 && xcnt > additionalRestrictions.Count)
            {
                foreach (var a in additionalRestrictions)
                {
                    if (!(a[rIdx] is DBNull) && Rational.Abs((Rational)a[rIdx]) == 1)
                    {
                        return; //Уже есть ограничение для этого Х
                    }
                }
                additionalRestrictions.Add(dt.NewRow());
                additionalRestrictions[additionalRestrictions.Count - 1][rIdx] = Rational.One;
                additionalRestrictions[additionalRestrictions.Count - 1][dt.Columns.Count - 1] =
                    (Rational)Math.Floor(result[rIdx].ToDouble());
                Iterate(additionalRestrictions);
                additionalRestrictions[additionalRestrictions.Count - 1][rIdx] = -Rational.One;
                additionalRestrictions[additionalRestrictions.Count - 1][dt.Columns.Count - 1] =
                    -(Rational)Math.Ceiling(result[rIdx].ToDouble());
                Iterate(additionalRestrictions);
                additionalRestrictions.RemoveAt(additionalRestrictions.Count - 1);
            }
        }