Skip to content

Commit 08df9b3

Browse files
committed
Code Maintenance
1 parent 557793b commit 08df9b3

59 files changed

Lines changed: 505 additions & 476 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 162 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,171 @@
1-
# This file is for unifying the coding style for different editors and IDEs.
2-
# More information at http://EditorConfig.org
3-
4-
root=true
1+
root = true
52

63
[*]
74
indent_style = space
85
indent_size = 4
6+
tab_width = 4
97
insert_final_newline = true
108
trim_trailing_whitespace = true
11-
tab_width=4
9+
10+
# Microsoft .NET properties
11+
csharp_new_line_before_members_in_object_initializers = false
12+
csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion
13+
csharp_style_var_elsewhere = true:suggestion
14+
csharp_style_var_for_built_in_types = true:suggestion
15+
csharp_style_var_when_type_is_apparent = true:suggestion
16+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
17+
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none
18+
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
19+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
20+
dotnet_style_predefined_type_for_member_access = true:suggestion
21+
dotnet_style_qualification_for_event = false:suggestion
22+
dotnet_style_qualification_for_field = false:suggestion
23+
dotnet_style_qualification_for_method = false:suggestion
24+
dotnet_style_qualification_for_property = false:suggestion
25+
file_header_template = <copyright file="{fileName}" company="Math.NET">\nMath.NET Numerics, part of the Math.NET Project\nhttps://numerics.mathdotnet.com\nhttps://github.com/mathnet/mathnet-numerics\n\nCopyright (c) 2009-$CURRENT_YEAR$ Math.NET\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the "Software"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n</copyright>
26+
27+
# ReSharper properties
28+
resharper_cpp_insert_final_newline = true
29+
resharper_csharp_insert_final_newline = true
30+
resharper_csharp_wrap_before_binary_opsign = true
31+
resharper_csharp_wrap_lines = false
32+
resharper_css_insert_final_newline = false
33+
resharper_default_private_modifier = implicit
34+
resharper_html_insert_final_newline = false
35+
resharper_js_insert_final_newline = false
36+
resharper_place_attribute_on_same_line = false
37+
resharper_protobuf_insert_final_newline = true
38+
resharper_resx_insert_final_newline = false
39+
resharper_vb_insert_final_newline = true
40+
resharper_xmldoc_insert_final_newline = true
41+
resharper_xml_insert_final_newline = true
42+
43+
# ReSharper inspection severities
44+
resharper_arrange_redundant_parentheses_highlighting = hint
45+
resharper_arrange_this_qualifier_highlighting = hint
46+
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
47+
resharper_built_in_type_reference_style_highlighting = hint
48+
resharper_redundant_base_qualifier_highlighting = warning
49+
resharper_suggest_var_or_type_built_in_types_highlighting = hint
50+
resharper_suggest_var_or_type_elsewhere_highlighting = hint
51+
resharper_suggest_var_or_type_simple_types_highlighting = hint
52+
csharp_indent_labels = one_less_than_current
53+
csharp_using_directive_placement = outside_namespace:silent
54+
csharp_prefer_simple_using_statement = true:suggestion
55+
csharp_prefer_braces = true:silent
56+
csharp_style_namespace_declarations = block_scoped:silent
57+
csharp_style_expression_bodied_methods = false:silent
58+
csharp_style_expression_bodied_constructors = false:silent
59+
csharp_style_expression_bodied_operators = false:silent
60+
csharp_style_expression_bodied_properties = true:silent
61+
csharp_style_expression_bodied_indexers = true:silent
62+
csharp_style_expression_bodied_accessors = true:silent
63+
csharp_style_expression_bodied_lambdas = true:silent
64+
csharp_style_expression_bodied_local_functions = false:silent
65+
csharp_style_throw_expression = true:suggestion
66+
csharp_style_prefer_null_check_over_type_check = true:suggestion
67+
csharp_prefer_simple_default_expression = true:suggestion
68+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
69+
csharp_space_around_binary_operators = before_and_after
70+
csharp_style_prefer_index_operator = true:suggestion
71+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
72+
csharp_style_prefer_range_operator = true:suggestion
73+
csharp_style_prefer_tuple_swap = true:suggestion
74+
csharp_style_inlined_variable_declaration = true:suggestion
75+
csharp_style_deconstructed_variable_declaration = true:suggestion
76+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
77+
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
78+
csharp_prefer_static_local_function = true:suggestion
79+
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
80+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
81+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
82+
csharp_style_conditional_delegate_call = true:suggestion
83+
csharp_style_prefer_pattern_matching = true:silent
84+
csharp_style_prefer_switch_expression = true:suggestion
85+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
86+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
87+
csharp_style_prefer_not_pattern = true:suggestion
88+
csharp_style_prefer_extended_property_pattern = true:suggestion
1289

1390
[*.md]
1491
trim_trailing_whitespace = false
92+
93+
[*.{asax,ascx,aspx,axaml,cs,css,js,jsx,master,paml,skin,ts,tsx,vb,xaml,xamlx,xoml}]
94+
indent_style = space
95+
indent_size = 4
96+
tab_width = 4
97+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
98+
dotnet_style_coalesce_expression = true:suggestion
99+
dotnet_style_null_propagation = true:suggestion
100+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
101+
dotnet_style_prefer_auto_properties = true:silent
102+
dotnet_style_object_initializer = true:suggestion
103+
dotnet_style_collection_initializer = true:suggestion
104+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
105+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
106+
dotnet_style_prefer_conditional_expression_over_return = true:silent
107+
dotnet_style_explicit_tuple_names = true:suggestion
108+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
109+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
110+
dotnet_style_prefer_compound_assignment = true:suggestion
111+
dotnet_style_prefer_simplified_interpolation = true:suggestion
112+
dotnet_style_namespace_match_folder = true:suggestion
113+
114+
[*.{json,resjson}]
115+
indent_style = space
116+
indent_size = 2
117+
tab_width = 2
118+
119+
[*.{cs,vb}]
120+
#### Naming styles ####
121+
122+
# Naming rules
123+
124+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
125+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
126+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
127+
128+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
129+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
130+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
131+
132+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
133+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
134+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
135+
136+
# Symbol specifications
137+
138+
dotnet_naming_symbols.interface.applicable_kinds = interface
139+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
140+
dotnet_naming_symbols.interface.required_modifiers =
141+
142+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
143+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
144+
dotnet_naming_symbols.types.required_modifiers =
145+
146+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
147+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
148+
dotnet_naming_symbols.non_field_members.required_modifiers =
149+
150+
# Naming styles
151+
152+
dotnet_naming_style.begins_with_i.required_prefix = I
153+
dotnet_naming_style.begins_with_i.required_suffix =
154+
dotnet_naming_style.begins_with_i.word_separator =
155+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
156+
157+
dotnet_naming_style.pascal_case.required_prefix =
158+
dotnet_naming_style.pascal_case.required_suffix =
159+
dotnet_naming_style.pascal_case.word_separator =
160+
dotnet_naming_style.pascal_case.capitalization = pascal_case
161+
162+
dotnet_naming_style.pascal_case.required_prefix =
163+
dotnet_naming_style.pascal_case.required_suffix =
164+
dotnet_naming_style.pascal_case.word_separator =
165+
dotnet_naming_style.pascal_case.capitalization = pascal_case
166+
dotnet_style_readonly_field = true:suggestion
167+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
168+
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
169+
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
170+
dotnet_code_quality_unused_parameters = all:suggestion
171+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent

MathNet.Numerics.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Numerics.Tests", "src\Numer
2626
EndProject
2727
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{B54A0B40-DE22-49FB-B1C0-6E5BDA3B0B2F}"
2828
ProjectSection(SolutionItems) = preProject
29+
.editorconfig = .editorconfig
2930
appveyor.yml = appveyor.yml
3031
Directory.Build.props = Directory.Build.props
3132
global.json = global.json

MathNet.Numerics.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING&#xD;
5454
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR&#xD;
5555
OTHER DEALINGS IN THE SOFTWARE.&#xD;
5656
&lt;/copyright&gt;</s:String>
57+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AVX/@EntryIndexedValue">AVX</s:String>
5758
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=BLAS/@EntryIndexedValue">BLAS</s:String>
5859
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CDF/@EntryIndexedValue">CDF</s:String>
5960
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CUDA/@EntryIndexedValue">CUDA</s:String>
@@ -78,6 +79,7 @@ OTHER DEALINGS IN THE SOFTWARE.&#xD;
7879
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SQR/@EntryIndexedValue">SQR</s:String>
7980
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SS/@EntryIndexedValue">SS</s:String>
8081
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSD/@EntryIndexedValue">SSD</s:String>
82+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SSE/@EntryIndexedValue">SSE</s:String>
8183
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=SVD/@EntryIndexedValue">SVD</s:String>
8284
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=TFQMR/@EntryIndexedValue">TFQMR</s:String>
8385
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=WH/@EntryIndexedValue">WH</s:String>

src/Data.Text/DelimitedReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static Matrix<T> Read<T>(TextReader reader, bool sparse = false, string d
8080
var mvStr = mv.ToString("G", formatProvider);
8181

8282
var regex = delimiter == @"\s" ?
83-
RegexCache.GetOrAdd(delimiter, d => new Regex(WhiteSpaceRegexTemplate, RegexOptions.Compiled)) :
83+
RegexCache.GetOrAdd(delimiter, _ => new Regex(WhiteSpaceRegexTemplate, RegexOptions.Compiled)) :
8484
RegexCache.GetOrAdd(delimiter, d => new Regex(string.Format(RegexTemplate, d), RegexOptions.Compiled));
8585

8686
var parse = CreateParser<T>(formatProvider);

src/Numerics.Tests/DifferentiationTests/NumericalHessianTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void ScalarFunctonSecondDerivativeTest()
4444
Func<double, double> f = x => Math.Pow(2 * x, 2);
4545
var J = new NumericalHessian();
4646
var jeval = J.Evaluate(f, 2);
47-
Assert.AreEqual((double)8, jeval[0], 1e-7);
47+
Assert.AreEqual(8.0, jeval[0], 1e-7);
4848
}
4949

5050
[Test]

src/Numerics/Distributions/Weibull.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ public static double CDF(double shape, double scale, double x)
400400
public static Weibull Estimate(IEnumerable<double> samples, System.Random randomSource = null)
401401
{
402402
var samp = samples as double[] ?? samples.ToArray();
403-
double n = samp.Length, s1 = 0, s2 = 0, s3 = 0, previousC = Int32.MinValue, QofC = 0;
403+
double n = samp.Length, s1, s2, s3, previousC = Int32.MinValue, QofC;
404404

405405
if (n <= 1) throw new Exception("Observations not sufficient");
406406

src/Numerics/Euclid.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ public static int Log2(this int number)
296296
return MultiplyDeBruijnBitPosition[(uint)(number * 0x07C4ACDDU) >> 27];
297297
}
298298

299-
static readonly int[] MultiplyDeBruijnBitPosition = new int[32]
300-
{
299+
static readonly int[] MultiplyDeBruijnBitPosition = {
301300
0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
302301
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
303302
};

src/Numerics/FindRoots.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static double[] ChebychevPolynomialFirstKind(int degree, double intervalB
139139
{
140140
if (degree < 1)
141141
{
142-
return new double[0];
142+
return Array.Empty<double>();
143143
}
144144

145145
// transform to map to [-1..1] interval
@@ -168,7 +168,7 @@ public static double[] ChebychevPolynomialSecondKind(int degree, double interval
168168
{
169169
if (degree < 1)
170170
{
171-
return new double[0];
171+
return Array.Empty<double>();
172172
}
173173

174174
// transform to map to [-1..1] interval

0 commit comments

Comments
 (0)