-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5a9590
commit 0c64357
Showing
5 changed files
with
211 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
|
||
Console.WriteLine("Hello, World!"); | ||
Console.WriteLine(Math.Abs(2.0 - Math.Pow(Math.Sqrt(2.0), 2)) < 1e-8); | ||
|
||
double Foo(double x) | ||
{ | ||
return x * x - 3 * x + Math.Sin(x / 2); | ||
} | ||
|
||
interface IIntegralSolver | ||
{ | ||
|
||
double Solve(Func<double, double> integrand, double leftBound, double rightBound, double epsilon); | ||
|
||
string Name { get; } | ||
|
||
} | ||
|
||
abstract class IntegralSolverBase : IIntegralSolver | ||
{ | ||
|
||
public double Solve(Func<double, double> integrand, double leftBound, double rightBound, double epsilon) | ||
{ | ||
if (integrand == null) | ||
{ | ||
throw new ArgumentNullException(nameof(integrand)); | ||
} | ||
|
||
if (epsilon <= 0) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(epsilon)); | ||
} | ||
|
||
if (rightBound - leftBound < epsilon) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(leftBound)); | ||
} | ||
|
||
return SolveInner(integrand, leftBound, rightBound, epsilon); | ||
} | ||
|
||
protected abstract double SolveInner(Func<double, double> integrand, double leftBound, double rightBound, double epsilon); | ||
|
||
public abstract string Name { get; } | ||
|
||
} | ||
|
||
sealed class LeftRectanglesIntegralSolver : IntegralSolverBase | ||
{ | ||
|
||
protected override double SolveInner(Func<double, double> integrand, double leftBound, double rightBound, | ||
double epsilon) | ||
{ | ||
// TODO: implement logic | ||
|
||
throw new NotImplementedException(); | ||
} | ||
|
||
public override string Name => | ||
"Left rectangles method"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters