Last active
April 26, 2025 10:17
-
-
Save trikitrok/6d4109430770706e000041833406c46c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public class ConjugatedGradient { | |
private readonly double tolerance; | |
private readonly int maxIterations; | |
public ConjugatedGradient(double tolerance = 1e-6, int maxIterations = 1000) { | |
this.tolerance = tolerance; | |
this.maxIterations = maxIterations; | |
} | |
public double[] Minimize( | |
Func<double[], double[]> gradFn, | |
double[] init | |
) { | |
// minimization code... | |
} | |
// more code... | |
} | |
public class LinearDescent { | |
public double[] Min( | |
Func<double[], double[]> gradFn, | |
double[] init, | |
Config config | |
) { | |
// minimization code... | |
} | |
// more code... | |
} | |
/////////////////////////////////// | |
public class ConjugatedGradient { | |
private readonly double tolerance; | |
private readonly int maxIterations; | |
public ConjugatedGradient(double tolerance = 1e-6, int maxIterations = 1000) { | |
this.tolerance = tolerance; | |
this.maxIterations = maxIterations; | |
} | |
public double[] Minimize( | |
Func<double[], double[]> gradFn, | |
double[] init | |
) { | |
// minimization code... | |
} | |
// more code... | |
} | |
public class LinearDescent { | |
private readonly double tolerance; | |
private readonly int maxIterations; | |
private readonly double learningRate; | |
public LinearDescent(double tolerance = 1e-6, int maxIterations = 1000, double learningRate = 0.01) { | |
this.tolerance = tolerance; | |
this.maxIterations = maxIterations; | |
this.learningRate = learningRate; | |
} | |
public double[] Minimize( | |
Func<double[], double[]> gradFn, | |
double[] init | |
) { | |
// minimization code... | |
} | |
// more code... | |
} | |
/////////////////////////////////// | |
public interface Minimization { | |
double[] Minimize( | |
Func<double[], double[]> gradFn, | |
double[] init | |
); | |
} | |
public class ConjugatedGradientMinimization : Minimization { | |
private readonly double tolerance; | |
private readonly int maxIterations; | |
public ConjugatedGradientMinimization(double tolerance = 1e-6, int maxIterations = 1000) { | |
this.tolerance = tolerance; | |
this.maxIterations = maxIterations; | |
} | |
public double[] Minimize( | |
Func<double[], double[]> gradFn, | |
double[] init | |
) { | |
// minimization code... | |
} | |
// more code... | |
} | |
public class LinearDescentMinimization : Minimization { | |
private readonly double tolerance; | |
private readonly int maxIterations; | |
private readonly double learningRate; | |
public LinearDescentMinimization(double tolerance = 1e-6, int maxIterations = 1000, double learningRate = 0.01) { | |
this.tolerance = tolerance; | |
this.maxIterations = maxIterations; | |
this.learningRate = learningRate; | |
} | |
public double[] Minimize( | |
Func<double[], double[]> gradFn, | |
double[] init | |
) { | |
// minimization code... | |
} | |
// more code... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment