diff --git a/examples/data_analysis_example/main.v b/examples/data_analysis_example/main.v index 6447158da..21f1169ef 100644 --- a/examples/data_analysis_example/main.v +++ b/examples/data_analysis_example/main.v @@ -86,23 +86,23 @@ fn main() { // Add traces for each class in the 3D plot plt_3d.scatter3d( - x: x1_class0 - y: x2_class0 - z: [][]f64{len: x1_class0.len, init: [0.0]} - mode: 'markers' + x: x1_class0 + y: x2_class0 + z: [][]f64{len: x1_class0.len, init: [0.0]} + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x1_class0.len, init: 8.0} + size: []f64{len: x1_class0.len, init: 8.0} color: []string{len: x1_class0.len, init: 'blue'} } name: 'Class 0' ) plt_3d.scatter3d( - x: x1_class1 - y: x2_class1 - z: [][]f64{len: x1_class1.len, init: [0.0]} - mode: 'markers' + x: x1_class1 + y: x2_class1 + z: [][]f64{len: x1_class1.len, init: [0.0]} + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x1_class1.len, init: 8.0} + size: []f64{len: x1_class1.len, init: 8.0} color: []string{len: x1_class1.len, init: 'red'} } name: 'Class 1' @@ -134,14 +134,14 @@ fn main() { mut plt_bars := plot.Plot.new() plt_bars.bar( - x: []string{len: stat.mean_x.len, init: 'Class ${index}'} - y: stat.mean_x + x: []string{len: stat.mean_x.len, init: 'Class ${index}'} + y: stat.mean_x name: 'Mean' ) plt_bars.bar( - x: []string{len: stat.sig_x.len, init: 'Class ${index}'} - y: stat.sig_x + x: []string{len: stat.sig_x.len, init: 'Class ${index}'} + y: stat.sig_x name: 'Standard Deviation' ) diff --git a/examples/fft_plot_example/main.v b/examples/fft_plot_example/main.v index 51ba8881d..de005ee15 100644 --- a/examples/fft_plot_example/main.v +++ b/examples/fft_plot_example/main.v @@ -26,9 +26,9 @@ fn main() { // Add a scatter plot for the original signal plt.scatter( - x: []f64{len: original_signal.len, init: f64(index)} - y: original_signal - mode: 'markers' + x: []f64{len: original_signal.len, init: f64(index)} + y: original_signal + mode: 'markers' marker: plot.Marker{ size: []f64{len: original_signal.len, init: 8.0} } @@ -37,9 +37,9 @@ fn main() { // Add a scatter plot for the imaginary part of the spectrum plt.scatter( - x: []f64{len: spectrum.len, init: f64(index)} - y: spectrum - mode: 'markers' + x: []f64{len: spectrum.len, init: f64(index)} + y: spectrum + mode: 'markers' marker: plot.Marker{ size: []f64{len: spectrum.len, init: 8.0} } diff --git a/examples/plot_annotated_pie_chart/main.v b/examples/plot_annotated_pie_chart/main.v index 53f9f740d..7d6a2f9b4 100644 --- a/examples/plot_annotated_pie_chart/main.v +++ b/examples/plot_annotated_pie_chart/main.v @@ -8,8 +8,8 @@ fn main() { mut plt := plot.Plot.new() plt.pie( - labels: labels - values: values + labels: labels + values: values textinfo: 'percent+label' ) plt.layout( diff --git a/examples/plot_basic_heatmap/main.v b/examples/plot_basic_heatmap/main.v index 2a53bebc5..129ae338d 100644 --- a/examples/plot_basic_heatmap/main.v +++ b/examples/plot_basic_heatmap/main.v @@ -15,8 +15,8 @@ fn main() { z: z ) plt.layout( - title: 'Heatmap Basic Implementation' - width: 750 + title: 'Heatmap Basic Implementation' + width: 750 height: 750 ) diff --git a/examples/plot_bubble_chart/main.v b/examples/plot_bubble_chart/main.v index 68ad2a5aa..1c350591d 100644 --- a/examples/plot_bubble_chart/main.v +++ b/examples/plot_bubble_chart/main.v @@ -9,11 +9,11 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y - mode: 'markers' + x: x + y: y + mode: 'markers' marker: plot.Marker{ - size: size + size: size color: []string{len: x.len * y.len, init: '#FF0000'} } name: 'Bubble Chart' diff --git a/examples/plot_grouped_bar_chart/main.v b/examples/plot_grouped_bar_chart/main.v index d0fcdd116..b906296be 100644 --- a/examples/plot_grouped_bar_chart/main.v +++ b/examples/plot_grouped_bar_chart/main.v @@ -9,13 +9,13 @@ fn main() { mut plt := plot.Plot.new() plt.bar( - x: categories - y: values1 + x: categories + y: values1 name: 'Group 1' ) plt.bar( - x: categories - y: values2 + x: categories + y: values2 name: 'Group 2' ) plt.layout( diff --git a/examples/plot_heatmap_golden_ratio/main.v b/examples/plot_heatmap_golden_ratio/main.v index c8e74eb79..af93c82a8 100644 --- a/examples/plot_heatmap_golden_ratio/main.v +++ b/examples/plot_heatmap_golden_ratio/main.v @@ -31,8 +31,8 @@ fn main() { z: z ) plt.layout( - title: 'Heatmap with Unequal Block Sizes' - width: 750 + title: 'Heatmap with Unequal Block Sizes' + width: 750 height: 750 ) diff --git a/examples/plot_histogram/main.v b/examples/plot_histogram/main.v index 180ed7307..f2638b43c 100644 --- a/examples/plot_histogram/main.v +++ b/examples/plot_histogram/main.v @@ -10,16 +10,16 @@ fn main() { mut plt := plot.Plot.new() plt.histogram( - x: x + x: x xbins: plot.Bins{ start: 0.0 - end: 100.0 - size: 2 + end: 100.0 + size: 2 } ) plt.layout( - title: 'Histogram Example' - width: 750 + title: 'Histogram Example' + width: 750 height: 750 ) plt.show()! diff --git a/examples/plot_line_axis_titles/main.v b/examples/plot_line_axis_titles/main.v index 7fe7d4e19..c1eaea2af 100644 --- a/examples/plot_line_axis_titles/main.v +++ b/examples/plot_line_axis_titles/main.v @@ -10,8 +10,8 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y1 + x: x + y: y1 mode: 'lines' line: plot.Line{ color: '#FF0000' @@ -19,8 +19,8 @@ fn main() { name: 'sin(x)' ) plt.scatter( - x: x - y: y2 + x: x + y: y2 mode: 'lines' line: plot.Line{ color: '#0000FF' diff --git a/examples/plot_line_plot_with_areas/main.v b/examples/plot_line_plot_with_areas/main.v index 6af4f913a..933a52871 100644 --- a/examples/plot_line_plot_with_areas/main.v +++ b/examples/plot_line_plot_with_areas/main.v @@ -10,8 +10,8 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y1 + x: x + y: y1 mode: 'lines' line: plot.Line{ color: '#FF0000' @@ -19,8 +19,8 @@ fn main() { name: 'sin(x)' ) plt.scatter( - x: x - y: y2 + x: x + y: y2 mode: 'lines' line: plot.Line{ color: '#0000FF' diff --git a/examples/plot_pie/main.v b/examples/plot_pie/main.v index 43f5f29da..5e98d37b0 100644 --- a/examples/plot_pie/main.v +++ b/examples/plot_pie/main.v @@ -8,12 +8,12 @@ fn main() { plt.pie( labels: ['Nitrogen', 'Oxygen', 'Argon', 'Other'] values: [78.0, 21, 0.9, 0.1] - pull: [0.0, 0.1, 0, 0] - hole: 0.25 + pull: [0.0, 0.1, 0, 0] + hole: 0.25 ) plt.layout( - title: 'Gases in the atmosphere' - width: 750 + title: 'Gases in the atmosphere' + width: 750 height: 750 ) plt.show()! diff --git a/examples/plot_ripple_surface/main.v b/examples/plot_ripple_surface/main.v index 442d4018e..3d2cdadc8 100644 --- a/examples/plot_ripple_surface/main.v +++ b/examples/plot_ripple_surface/main.v @@ -20,9 +20,9 @@ fn main() { mut plt := plot.Plot.new() plt.surface( - x: x - y: y - z: z + x: x + y: y + z: z colorscale: 'Viridis' ) plt.layout( diff --git a/examples/plot_saddle_surface/main.v b/examples/plot_saddle_surface/main.v index 372662d74..5cbf9a381 100644 --- a/examples/plot_saddle_surface/main.v +++ b/examples/plot_saddle_surface/main.v @@ -19,9 +19,9 @@ fn main() { mut plt := plot.Plot.new() plt.surface( - x: x - y: y - z: z + x: x + y: y + z: z colorscale: 'Viridis' ) plt.layout( diff --git a/examples/plot_scatter/main.v b/examples/plot_scatter/main.v index cecbf902a..cba3e373e 100644 --- a/examples/plot_scatter/main.v +++ b/examples/plot_scatter/main.v @@ -23,11 +23,11 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y - mode: 'lines+markers' + x: x + y: y + mode: 'lines+markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 10.0} + size: []f64{len: x.len, init: 10.0} color: []string{len: x.len, init: '#FF0000'} } line: plot.Line{ diff --git a/examples/plot_scatter3d_1/main.v b/examples/plot_scatter3d_1/main.v index 21be058d4..cdf55bc6f 100644 --- a/examples/plot_scatter3d_1/main.v +++ b/examples/plot_scatter3d_1/main.v @@ -24,12 +24,12 @@ fn main() { mut plt := plot.Plot.new() plt.scatter3d( - x: x - y: y - z: z - mode: 'lines+markers' + x: x + y: y + z: z + mode: 'lines+markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 10.0} + size: []f64{len: x.len, init: 10.0} color: []string{len: x.len, init: '#0000FF'} } line: plot.Line{ diff --git a/examples/plot_scatter3d_2/main.v b/examples/plot_scatter3d_2/main.v index 9eda8acf2..6f540b999 100644 --- a/examples/plot_scatter3d_2/main.v +++ b/examples/plot_scatter3d_2/main.v @@ -17,12 +17,12 @@ fn main() { mut plt := plot.Plot.new() plt.scatter3d( - x: x - y: y - z: z - mode: 'markers' + x: x + y: y + z: z + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 15.0} + size: []f64{len: x.len, init: 15.0} color: []string{len: x.len, init: '#0000FF'} } ) diff --git a/examples/plot_scatter3d_easing/main.v b/examples/plot_scatter3d_easing/main.v index 701a7f9c6..0bde7d50d 100644 --- a/examples/plot_scatter3d_easing/main.v +++ b/examples/plot_scatter3d_easing/main.v @@ -17,14 +17,14 @@ fn main() { // Create the Scatter3D plot mut plt := plot.Plot.new() plt.scatter3d( - name: 'Easing Scatter3D' - x: x_values - y: y_values - z: [][]f64{len: z_values.len, init: z_values} - mode: 'markers' + name: 'Easing Scatter3D' + x: x_values + y: y_values + z: [][]f64{len: z_values.len, init: z_values} + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x_values.len, init: 10.0} - color: time // Color based on time + size: []f64{len: x_values.len, init: 10.0} + color: time // Color based on time colorscale: 'viridis' } ) diff --git a/examples/plot_scatter_colorscale/main.v b/examples/plot_scatter_colorscale/main.v index 83d8cd0ee..7a1881bb5 100644 --- a/examples/plot_scatter_colorscale/main.v +++ b/examples/plot_scatter_colorscale/main.v @@ -23,11 +23,11 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y - mode: 'lines+markers' + x: x + y: y + mode: 'lines+markers' colorscale: 'smoker' - marker: plot.Marker{ + marker: plot.Marker{ size: []f64{len: x.len, init: 10.0} } ) diff --git a/examples/plot_scatter_easing/main.v b/examples/plot_scatter_easing/main.v index aa0f1899e..641c3efea 100644 --- a/examples/plot_scatter_easing/main.v +++ b/examples/plot_scatter_easing/main.v @@ -16,14 +16,14 @@ fn main() { // Create the Scatter plot mut plt := plot.Plot.new() plt.scatter( - name: 'Easing Scatter' - x: x_values - y: y_values - mode: 'markers' + name: 'Easing Scatter' + x: x_values + y: y_values + mode: 'markers' colorscale: 'viridis' - marker: plot.Marker{ - size: []f64{len: x_values.len, init: 10.0} - color: time // Color based on time + marker: plot.Marker{ + size: []f64{len: x_values.len, init: 10.0} + color: time // Color based on time colorscale: 'viridis' } ) diff --git a/examples/plot_scatter_with_annotations/main.v b/examples/plot_scatter_with_annotations/main.v index 37eca61ae..c836f9c96 100644 --- a/examples/plot_scatter_with_annotations/main.v +++ b/examples/plot_scatter_with_annotations/main.v @@ -22,11 +22,11 @@ fn main() { x := util.arange(y.len) mut plt := plot.Plot.new() plt.scatter( - x: x - y: y - mode: 'lines+markers' + x: x + y: y + mode: 'lines+markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 10.0} + size: []f64{len: x.len, init: 10.0} color: []string{len: x.len, init: '#FF0000'} } line: plot.Line{ @@ -34,7 +34,7 @@ fn main() { } ) plt.layout( - title: 'Scatter plot example' + title: 'Scatter plot example' annotations: [plot.Annotation{ text: 'test annotation' }] diff --git a/examples/plot_scatter_with_bars/main.v b/examples/plot_scatter_with_bars/main.v index a5660344d..b5b5ad782 100644 --- a/examples/plot_scatter_with_bars/main.v +++ b/examples/plot_scatter_with_bars/main.v @@ -9,17 +9,17 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y - mode: 'markers' + x: x + y: y + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 10.0} + size: []f64{len: x.len, init: 10.0} color: []string{len: x.len, init: '#FF0000'} } ) plt.bar( - x: x.map(it.str()) - y: y + x: x.map(it.str()) + y: y marker: plot.Marker{ color: []string{len: x.len, init: '#0000FF'} } diff --git a/examples/plot_scatter_with_histogram/main.v b/examples/plot_scatter_with_histogram/main.v index 2ba11c7f7..531f321d7 100644 --- a/examples/plot_scatter_with_histogram/main.v +++ b/examples/plot_scatter_with_histogram/main.v @@ -10,11 +10,11 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: x - mode: 'markers' + x: x + y: x + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 10.0} + size: []f64{len: x.len, init: 10.0} color: []string{len: x.len, init: '#FF0000'} } ) diff --git a/examples/plot_scatter_with_regression/main.v b/examples/plot_scatter_with_regression/main.v index 47c15a8db..2c3250862 100644 --- a/examples/plot_scatter_with_regression/main.v +++ b/examples/plot_scatter_with_regression/main.v @@ -8,18 +8,18 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y - mode: 'markers' + x: x + y: y + mode: 'markers' marker: plot.Marker{ - size: []f64{len: x.len, init: 10.0} + size: []f64{len: x.len, init: 10.0} color: []string{len: x.len, init: '#00FF00'} } name: 'Data Points' ) plt.scatter( - x: x - y: y + x: x + y: y mode: 'lines' line: plot.Line{ color: '#FF0000' diff --git a/examples/plot_script_mode_three_phase_signal/main.v b/examples/plot_script_mode_three_phase_signal/main.v index 69605ab14..bc4e628ee 100644 --- a/examples/plot_script_mode_three_phase_signal/main.v +++ b/examples/plot_script_mode_three_phase_signal/main.v @@ -13,20 +13,20 @@ y3 := t.map(a0 * math.sin(2 * math.pi * f * it + 4 * math.pi / 3)) // y₃ = A mut plt := plot.Plot.new() plt.scatter( - x: t - y: y1 + x: t + y: y1 name: 'y1(t)' ) plt.scatter( - x: t - y: y2 + x: t + y: y2 name: 'y2(t)' ) plt.scatter( - x: t - y: y3 + x: t + y: y3 name: 'y3(t)' ) diff --git a/examples/plot_shaded_area_sin/main.v b/examples/plot_shaded_area_sin/main.v index 83d0044f1..a97e701c7 100644 --- a/examples/plot_shaded_area_sin/main.v +++ b/examples/plot_shaded_area_sin/main.v @@ -9,8 +9,8 @@ fn main() { mut plt := plot.Plot.new() plt.scatter( - x: x - y: y + x: x + y: y mode: 'lines' line: plot.Line{ color: '#0000FF' @@ -18,12 +18,12 @@ fn main() { name: 'sin(x)' ) plt.scatter( - x: x - y: []f64{len: x.len} - mode: 'lines' - fill: 'tozeroy' + x: x + y: []f64{len: x.len} + mode: 'lines' + fill: 'tozeroy' fillcolor: 'rgba(0, 0, 255, 0.2)' - line: plot.Line{ + line: plot.Line{ color: 'rgba(0, 0, 255, 0)' } name: 'Shaded Area' diff --git a/examples/plot_sin_cos_surface/main.v b/examples/plot_sin_cos_surface/main.v index 4d8ab3cbd..b949a574e 100644 --- a/examples/plot_sin_cos_surface/main.v +++ b/examples/plot_sin_cos_surface/main.v @@ -19,9 +19,9 @@ fn main() { mut plt := plot.Plot.new() plt.surface( - x: x - y: y - z: z + x: x + y: y + z: z colorscale: 'Viridis' ) plt.layout( diff --git a/examples/plot_surface/main.v b/examples/plot_surface/main.v index f383fa627..20527d34d 100644 --- a/examples/plot_surface/main.v +++ b/examples/plot_surface/main.v @@ -19,9 +19,9 @@ fn main() { mut plt := plot.Plot.new() plt.surface( - x: x - y: y - z: z + x: x + y: y + z: z colorscale: 'Viridis' ) plt.layout( diff --git a/examples/plot_surface_easing/main.v b/examples/plot_surface_easing/main.v index e25adb148..8de21f6b9 100644 --- a/examples/plot_surface_easing/main.v +++ b/examples/plot_surface_easing/main.v @@ -15,10 +15,10 @@ fn main() { // Create the Surface plot mut plt := plot.Plot.new() plt.surface( - name: 'Easing Surface' - x: x_values - y: y_values - z: [][]f64{len: z_values.len, init: z_values} + name: 'Easing Surface' + x: x_values + y: y_values + z: [][]f64{len: z_values.len, init: z_values} colorscale: 'viridis' ) diff --git a/examples/roots_bisection_solver/main.v b/examples/roots_bisection_solver/main.v index 0b562f4d3..8a2c6d5ba 100644 --- a/examples/roots_bisection_solver/main.v +++ b/examples/roots_bisection_solver/main.v @@ -39,17 +39,17 @@ fn main() { y := x.map(f_cos(it, []f64{})) plt.scatter( - x: x - y: y + x: x + y: y mode: 'lines' line: plot.Line{ color: '#FF0000' } ) plt.scatter( - x: [result.x] - y: [result.fx] - mode: 'markers' + x: [result.x] + y: [result.fx] + mode: 'markers' marker: plot.Marker{ color: ['#0000FF'] } diff --git a/float/float32/axpy_test.v b/float/float32/axpy_test.v index bab7d5dda..9bdc44de8 100644 --- a/float/float32/axpy_test.v +++ b/float/float32/axpy_test.v @@ -2,87 +2,87 @@ module float32 const axpy_tests = [ AxpyTest{ - alpha: f32(0.0) - x: []f32{} - y: []f32{} - want: []f32{} + alpha: f32(0.0) + x: []f32{} + y: []f32{} + want: []f32{} want_rev: []f32{} }, AxpyTest{ - alpha: f32(0) - x: [f32(2.0)] - y: [f32(-3.0)] - want: [f32(-3.0)] + alpha: f32(0) + x: [f32(2.0)] + y: [f32(-3.0)] + want: [f32(-3.0)] want_rev: [f32(-3.0)] }, AxpyTest{ - alpha: f32(1.0) - x: [f32(2.0)] - y: [f32(-3.0)] - want: [f32(-1.0)] + alpha: f32(1.0) + x: [f32(2.0)] + y: [f32(-3.0)] + want: [f32(-1.0)] want_rev: [f32(-1.0)] }, AxpyTest{ - alpha: f32(3.0) - x: [f32(2.0)] - y: [f32(-3.0)] - want: [f32(3.0)] + alpha: f32(3.0) + x: [f32(2.0)] + y: [f32(-3.0)] + want: [f32(3.0)] want_rev: [f32(3.0)] }, AxpyTest{ - alpha: f32(-3.0) - x: [f32(2.0)] - y: [f32(-3.0)] - want: [f32(-9.0)] + alpha: f32(-3.0) + x: [f32(2.0)] + y: [f32(-3.0)] + want: [f32(-9.0)] want_rev: [f32(-9.0)] }, AxpyTest{ - alpha: f32(1.0) - x: [f32(1.0), 5] - y: [f32(2.0), -3] - want: [f32(3.0), 2] + alpha: f32(1.0) + x: [f32(1.0), 5] + y: [f32(2.0), -3] + want: [f32(3.0), 2] want_rev: [f32(7.0), -2] }, AxpyTest{ - alpha: f32(1.0) - x: [f32(2.0), 3, 4] - y: [f32(-3.0), -2, -1] - want: [f32(-1.0), 1, 3] + alpha: f32(1.0) + x: [f32(2.0), 3, 4] + y: [f32(-3.0), -2, -1] + want: [f32(-1.0), 1, 3] want_rev: [f32(1.0), 1, 1] }, AxpyTest{ - alpha: f32(0.0) - x: [f32(0.0), 0, 1, 1, 2, -3, -4] - y: [f32(0.0), 1, 0, 3, -4, 5, -6] - want: [f32(0.0), 1, 0, 3, -4, 5, -6] + alpha: f32(0.0) + x: [f32(0.0), 0, 1, 1, 2, -3, -4] + y: [f32(0.0), 1, 0, 3, -4, 5, -6] + want: [f32(0.0), 1, 0, 3, -4, 5, -6] want_rev: [f32(0.0), 1, 0, 3, -4, 5, -6] }, AxpyTest{ - alpha: f32(1.0) - x: [f32(0.0), 0, 1, 1, 2, -3, -4] - y: [f32(0.0), 1, 0, 3, -4, 5, -6] - want: [f32(0.0), 1, 1, 4, -2, 2, -10] + alpha: f32(1.0) + x: [f32(0.0), 0, 1, 1, 2, -3, -4] + y: [f32(0.0), 1, 0, 3, -4, 5, -6] + want: [f32(0.0), 1, 1, 4, -2, 2, -10] want_rev: [f32(-4.0), -2, 2, 4, -3, 5, -6] }, AxpyTest{ - alpha: f32(3.0) - x: [f32(0.0), 0, 1, 1, 2, -3, -4] - y: [f32(0.0), 1, 0, 3, -4, 5, -6] - want: [f32(0.0), 1, 3, 6, 2, -4, -18] + alpha: f32(3.0) + x: [f32(0.0), 0, 1, 1, 2, -3, -4] + y: [f32(0.0), 1, 0, 3, -4, 5, -6] + want: [f32(0.0), 1, 3, 6, 2, -4, -18] want_rev: [f32(-12.0), -8, 6, 6, -1, 5, -6] }, AxpyTest{ - alpha: f32(-3.0) - x: [f32(0.0), 0, 1, 1, 2, -3, -4, 0, 0, 1, 1, 2, -3, -4] - y: [f32(0.0), 1, 0, 3, -4, 5, -6, 0, 1, 0, 3, -4, 5, -6] - want: [f32(0.0), 1, -3, 0, -10, 14, 6, 0, 1, -3, 0, -10, 14, 6] + alpha: f32(-3.0) + x: [f32(0.0), 0, 1, 1, 2, -3, -4, 0, 0, 1, 1, 2, -3, -4] + y: [f32(0.0), 1, 0, 3, -4, 5, -6, 0, 1, 0, 3, -4, 5, -6] + want: [f32(0.0), 1, -3, 0, -10, 14, 6, 0, 1, -3, 0, -10, 14, 6] want_rev: [f32(12.0), 10, -6, 0, -7, 5, -6, 12, 10, -6, 0, -7, 5, -6] }, AxpyTest{ - alpha: f32(-5.0) - x: [f32(0.0), 0, 1, 1, 2, -3, -4, 5, 1, 2, -3, -4, 5] - y: [f32(0.0), 1, 0, 3, -4, 5, -6, 7, 3, -4, 5, -6, 7] - want: [f32(0.0), 1, -5, -2, -14, 20, 14, -18, -2, -14, 20, 14, -18] + alpha: f32(-5.0) + x: [f32(0.0), 0, 1, 1, 2, -3, -4, 5, 1, 2, -3, -4, 5] + y: [f32(0.0), 1, 0, 3, -4, 5, -6, 7, 3, -4, 5, -6, 7] + want: [f32(0.0), 1, -5, -2, -14, 20, 14, -18, -2, -14, 20, 14, -18] want_rev: [f32(-25.0), 21, 15, -7, -9, -20, 14, 22, -7, -9, 0, -6, 7] }, ] @@ -98,7 +98,7 @@ struct AxpyTest { fn test_axpy_unitary() { x_gd_val, y_gd_val := f32(-1.0), f32(1.5) - for test in float32.axpy_tests { + for test in axpy_tests { for align in align2 { xg_ln, yg_ln := 4 + align.x, 4 + align.y xg, yg := guard_vector(test.x, x_gd_val, xg_ln), guard_vector(test.y, y_gd_val, @@ -120,7 +120,7 @@ fn test_axpy_unitary() { fn test_axpy_unitary_to() { dst_gd_val, x_gd_val, y_gd_val := f32(1.0), f32(-1.0), f32(1.5) - for test in float32.axpy_tests { + for test in axpy_tests { for align in align3 { dg_ln, xg_ln, yg_ln := 4 + align.dst, 4 + align.x, 4 + align.y dst_orig := []f32{len: test.x.len} @@ -148,7 +148,7 @@ fn test_axpy_inc() { x_gd_val, y_gd_val := f32(-1.0), f32(1.5) gd_ln := 4 - for test in float32.axpy_tests { + for test in axpy_tests { n := test.x.len for inc in IncSet.new(-7, -4, -3, -2, -1, 1, 2, 3, 4, 7) { @@ -188,7 +188,7 @@ fn test_axpy_inc_to() { dst_gd_val, x_gd_val, y_gd_val := 1, f32(-1.0), f32(1.5) gd_ln := 4 - for test in float32.axpy_tests { + for test in axpy_tests { n := test.x.len for inc in IncToSet.new(-7, -4, -3, -2, -1, 1, 2, 3, 4, 7) { diff --git a/float/float32/dot_test.v b/float/float32/dot_test.v index ea2ceaf30..75a46e95a 100644 --- a/float/float32/dot_test.v +++ b/float/float32/dot_test.v @@ -11,57 +11,57 @@ struct DotTest { const dot_tests = [ DotTest{ - x: [f32(2.0)] - y: [f32(-3.0)] - want: -6 + x: [f32(2.0)] + y: [f32(-3.0)] + want: -6 want_rev: -6 }, DotTest{ - x: [f32(2.0), 3] - y: [f32(-3.0), 4] - want: 6 + x: [f32(2.0), 3] + y: [f32(-3.0), 4] + want: 6 want_rev: -1 }, DotTest{ - x: [f32(2.0), 3, -4] - y: [f32(-3.0), 4, 5] - want: -14 + x: [f32(2.0), 3, -4] + y: [f32(-3.0), 4, 5] + want: -14 want_rev: 34 }, DotTest{ - x: [f32(2.0), 3, -4, -5] - y: [f32(-3.0), 4, 5, -6] - want: 16 + x: [f32(2.0), 3, -4, -5] + y: [f32(-3.0), 4, 5, -6] + want: 16 want_rev: 2 }, DotTest{ - x: [f32(0.0), 2, 3, -4, -5] - y: [f32(0.0), -3, 4, 5, -6] - want: 16 + x: [f32(0.0), 2, 3, -4, -5] + y: [f32(0.0), -3, 4, 5, -6] + want: 16 want_rev: 34 }, DotTest{ - x: [f32(0.0), 0, 2, 3, -4, -5] - y: [f32(0.0), 1, -3, 4, 5, -6] - want: 16 + x: [f32(0.0), 0, 2, 3, -4, -5] + y: [f32(0.0), 1, -3, 4, 5, -6] + want: 16 want_rev: -5 }, DotTest{ - x: [f32(0.0), 0, 1, 1, 2, -3, -4] - y: [f32(0.0), 1, 0, 3, -4, 5, -6] - want: 4 + x: [f32(0.0), 0, 1, 1, 2, -3, -4] + y: [f32(0.0), 1, 0, 3, -4, 5, -6] + want: 4 want_rev: -4 }, DotTest{ - x: [f32(0.0), 0, 1, 1, 2, -3, -4, 5] - y: [f32(0.0), 1, 0, 3, -4, 5, -6, 7] - want: 39 + x: [f32(0.0), 0, 1, 1, 2, -3, -4, 5] + y: [f32(0.0), 1, 0, 3, -4, 5, -6, 7] + want: 39 want_rev: 3 }, ] fn test_dot_unitary() { - for i, test in float32.dot_tests { + for i, test in dot_tests { x, x_front, x_back := new_guarded_vector(test.x, 1) y, y_front, y_back := new_guarded_vector(test.y, 1) got := dot_unitary(x, y) @@ -82,7 +82,7 @@ fn test_dot_unitary() { } fn test_dot_inc() { - for i, test in float32.dot_tests { + for i, test in dot_tests { for incx in [-7, -3, -2, -1, 1, 2, 3, 7] { for incy in [-7, -3, -2, -1, 1, 2, 3, 7] { n := test.x.len diff --git a/float/float32/ge_test.v b/float/float32/ge_test.v index 7f8727263..57af56945 100644 --- a/float/float32/ge_test.v +++ b/float/float32/ge_test.v @@ -4,27 +4,27 @@ import math const ge_tests = [// m x n ( kernels executed ) GeTest{ // 1 x 1 (1x1) - x: [f32(2.0)] - y: [f32(4.4)] - a: [f32(10.0)] + x: [f32(2.0)] + y: [f32(4.4)] + a: [f32(10.0)] want: [f32(18.8)] }, GeTest{ // 3 x 2 ( 2x2, 1x2 ) - x: [f32(-2.0), -3, 0] - y: [f32(-1.1), 5] - a: [f32(1.3), 2.4, 2.6, 2.8, -1.3, -4.3] + x: [f32(-2.0), -3, 0] + y: [f32(-1.1), 5] + a: [f32(1.3), 2.4, 2.6, 2.8, -1.3, -4.3] want: [f32(3.5), -7.6, 5.9, -12.2, -1.3, -4.3] }, GeTest{ // 3 x 3 ( 2x2, 2x1, 1x2, 1x1 ) - x: [f32(-2.0), 7, 12] - y: [f32(-1.1), 0, 6] - a: [f32(1.3), 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7] + x: [f32(-2.0), 7, 12] + y: [f32(-1.1), 0, 6] + a: [f32(1.3), 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7] want: [f32(3.5), 2.4, -8.5, -5.1, 2.8, 45.3, -14.5, -4.3, 62.3] }, GeTest{ // 5 x 3 ( 4x2, 4x1, 1x2, 1x1 ) - x: [f32(-2.0), -3, 0, 1, 2] - y: [f32(-1.1), 5, 0] - a: [f32(1.3), 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7, 8, 9, -10, -12, -14, -6] + x: [f32(-2.0), -3, 0, 1, 2] + y: [f32(-1.1), 5, 0] + a: [f32(1.3), 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7, 8, 9, -10, -12, -14, -6] want: [f32(3.5), -7.6, 3.5, 5.9, -12.2, 3.3, -1.3, -4.3, -9.7, 6.9, 14, -10, -14.2, -4, -6] }, @@ -71,7 +71,7 @@ fn test_ger() { x_gd_val, y_gd_val, a_gd_val := f32(-0.5), f32(1.5), 10 gd_ln := 4 - for test in float32.ge_tests { + for test in ge_tests { m := test.x.len n := test.y.len for align in align2 { diff --git a/float/float32/l2norm_test.v b/float/float32/l2norm_test.v index a9f454343..8c229c126 100644 --- a/float/float32/l2norm_test.v +++ b/float/float32/l2norm_test.v @@ -17,31 +17,31 @@ fn test_l2_norm_unitary() { l2_norm_unitary_tests := [ L2NormTest{ want: f32(0.0) - x: []f32{} + x: []f32{} }, L2NormTest{ want: f32(2.0) - x: [f32(2.0)] + x: [f32(2.0)] }, L2NormTest{ want: f32(3.7416573867739413) - x: [f32(1.0), 2, 3] + x: [f32(1.0), 2, 3] }, L2NormTest{ want: f32(3.7416573867739413) - x: [f32(-1.0), -2, -3] + x: [f32(-1.0), -2, -3] }, L2NormTest{ want: f32(math.nan()) - x: [f32(math.nan())] + x: [f32(math.nan())] }, L2NormTest{ want: f32(17.88854381999832) - x: [f32(8.0), -8, 8, -8, 8] + x: [f32(8.0), -8, 8, -8, 8] }, L2NormTest{ want: f32(2.23606797749979) - x: [f32(0.0), 1, 0, -1, 0, 1, 0, -1, 0, 1] + x: [f32(0.0), 1, 0, -1, 0, 1, 0, -1, 0, 1] }, ] @@ -62,39 +62,39 @@ fn test_l2_norm_inc() { l2_norm_inc_tests := [ L2NormTest{ - inc: 2 + inc: 2 want: f32(0.0) - x: []f32{} + x: []f32{} }, L2NormTest{ - inc: 3 + inc: 3 want: f32(2.0) - x: [f32(2.0)] + x: [f32(2.0)] }, L2NormTest{ - inc: 10 + inc: 10 want: f32(3.7416573867739413) - x: [f32(1.0), 2, 3] + x: [f32(1.0), 2, 3] }, L2NormTest{ - inc: 5 + inc: 5 want: f32(3.7416573867739413) - x: [f32(-1.0), -2, -3] + x: [f32(-1.0), -2, -3] }, L2NormTest{ - inc: 3 + inc: 3 want: f32(math.nan()) - x: [f32(math.nan())] + x: [f32(math.nan())] }, L2NormTest{ - inc: 15 + inc: 15 want: f32(17.88854381999832) - x: [f32(8.0), -8, 8, -8, 8] + x: [f32(8.0), -8, 8, -8, 8] }, L2NormTest{ - inc: 1 + inc: 1 want: f32(2.23606797749979) - x: [f32(0.0), 1, 0, -1, 0, 1, 0, -1, 0, 1] + x: [f32(0.0), 1, 0, -1, 0, 1, 0, -1, 0, 1] }, ] @@ -116,38 +116,38 @@ fn test_l2_distance_unitary() { l2_distance_unitary_tests := [ L2NormTest{ want: f32(0.0) - x: []f32{} - y: []f32{} + x: []f32{} + y: []f32{} }, L2NormTest{ want: f32(2.0) - x: [f32(3.0)] - y: [f32(1.0)] + x: [f32(3.0)] + y: [f32(1.0)] }, L2NormTest{ want: f32(3.7416573867739413) - x: [f32(2.0), 4, 6] - y: [f32(1.0), 2, 3] + x: [f32(2.0), 4, 6] + y: [f32(1.0), 2, 3] }, L2NormTest{ want: f32(3.7416573867739413) - x: [f32(1.0), 2, 3] - y: [f32(2.0), 4, 6] + x: [f32(1.0), 2, 3] + y: [f32(2.0), 4, 6] }, L2NormTest{ want: f32(math.nan()) - x: [f32(math.nan())] - y: [f32(0.0)] + x: [f32(math.nan())] + y: [f32(0.0)] }, L2NormTest{ want: f32(17.88854381999832) - x: [f32(9.0), -9, 9, -9, 9] - y: [f32(1.0), -1, 1, -1, 1] + x: [f32(9.0), -9, 9, -9, 9] + y: [f32(1.0), -1, 1, -1, 1] }, L2NormTest{ want: f32(2.23606797749979) - x: [f32(0.0), 1, 0, -1, 0, 1, 0, -1, 0, 1] - y: [f32(0.0), 2, 0, -2, 0, 2, 0, -2, 0, 2] + x: [f32(0.0), 1, 0, -1, 0, 1, 0, -1, 0, 1] + y: [f32(0.0), 2, 0, -2, 0, 2, 0, -2, 0, 2] }, ] diff --git a/float/float32/scal_test.v b/float/float32/scal_test.v index 3c0452d3e..9c57fed8f 100644 --- a/float/float32/scal_test.v +++ b/float/float32/scal_test.v @@ -11,65 +11,65 @@ struct ScalTest { const scal_tests = [ ScalTest{ alpha: f32(0.0) - x: []f32{} - want: []f32{} + x: []f32{} + want: []f32{} }, ScalTest{ alpha: f32(0.0) - x: [f32(1.0)] - want: [f32(0.0)] + x: [f32(1.0)] + want: [f32(0.0)] }, ScalTest{ alpha: f32(1.0) - x: [f32(1.0)] - want: [f32(1.0)] + x: [f32(1.0)] + want: [f32(1.0)] }, ScalTest{ alpha: f32(2.0) - x: [f32(1.0), -2] - want: [f32(2.0), -4] + x: [f32(1.0), -2] + want: [f32(2.0), -4] }, ScalTest{ alpha: f32(2.0) - x: [f32(1.0), -2, 3] - want: [f32(2.0), -4, 6] + x: [f32(1.0), -2, 3] + want: [f32(2.0), -4, 6] }, ScalTest{ alpha: f32(2.0) - x: [f32(1.0), -2, 3, 4] - want: [f32(2.0), -4, 6, 8] + x: [f32(1.0), -2, 3, 4] + want: [f32(2.0), -4, 6, 8] }, ScalTest{ alpha: f32(2.0) - x: [f32(1.0), -2, 3, 4, -5] - want: [f32(2.0), -4, 6, 8, -10] + x: [f32(1.0), -2, 3, 4, -5] + want: [f32(2.0), -4, 6, 8, -10] }, ScalTest{ alpha: f32(2.0) - x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7] - want: [f32(0.0), 2, -4, 6, 8, -10, 12, -14] + x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7] + want: [f32(0.0), 2, -4, 6, 8, -10, 12, -14] }, ScalTest{ alpha: f32(2.0) - x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7, 8] - want: [f32(0.0), 2, -4, 6, 8, -10, 12, -14, 16] + x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7, 8] + want: [f32(0.0), 2, -4, 6, 8, -10, 12, -14, 16] }, ScalTest{ alpha: f32(2.0) - x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7, 8, 9] - want: [f32(0.0), 2, -4, 6, 8, -10, 12, -14, 16, 18] + x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7, 8, 9] + want: [f32(0.0), 2, -4, 6, 8, -10, 12, -14, 16, 18] }, ScalTest{ alpha: f32(3.0) - x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7, 8, 9, 12] - want: [f32(0.0), 3, -6, 9, 12, -15, 18, -21, 24, 27, 36] + x: [f32(0.0), 1, -2, 3, 4, -5, 6, -7, 8, 9, 12] + want: [f32(0.0), 3, -6, 9, 12, -15, 18, -21, 24, 27, 36] }, ] fn test_scal_unitary() { x_gd_val := f32(-0.5) - for test in float32.scal_tests { + for test in scal_tests { for align in align1 { xg_ln := 4 + align xg := guard_vector(test.x, x_gd_val, xg_ln) @@ -90,7 +90,7 @@ fn test_scal_unitary_to() { rand.seed([u32(42), u32(42)]) x_gd_val, dst_gd_val := f32(-1.0), f32(0.5) - for test in float32.scal_tests { + for test in scal_tests { n := test.x.len for align in align2 { xg_ln, dg_ln := 4 + align.x, 4 + align.y @@ -116,7 +116,7 @@ fn test_scal_inc() { x_gd_val := f32(-0.5) gd_ln := 4 - for test in float32.scal_tests { + for test in scal_tests { n := test.x.len for incx in [1, 2, 3, 4, 7, 10] { xg := guard_inc_vector(test.x, x_gd_val, incx, gd_ln) @@ -138,7 +138,7 @@ fn test_scal_inc_to() { x_gd_val, dst_gd_val := f32(-1.0), f32(0.5) gd_ln := 4 - for test in float32.scal_tests { + for test in scal_tests { n := test.x.len for inc in IncSet.new(1, 2, 3, 4, 7, 10) { xg := guard_inc_vector(test.x, x_gd_val, inc.x, gd_ln) diff --git a/float/float64/axpy_test.v b/float/float64/axpy_test.v index 203383175..9d6c40cc4 100644 --- a/float/float64/axpy_test.v +++ b/float/float64/axpy_test.v @@ -2,87 +2,87 @@ module float64 const axpy_tests = [ AxpyTest{ - alpha: 0.0 - x: []f64{} - y: []f64{} - want: []f64{} + alpha: 0.0 + x: []f64{} + y: []f64{} + want: []f64{} want_rev: []f64{} }, AxpyTest{ - alpha: 0 - x: [2.0] - y: [-3.0] - want: [-3.0] + alpha: 0 + x: [2.0] + y: [-3.0] + want: [-3.0] want_rev: [-3.0] }, AxpyTest{ - alpha: 1.0 - x: [2.0] - y: [-3.0] - want: [-1.0] + alpha: 1.0 + x: [2.0] + y: [-3.0] + want: [-1.0] want_rev: [-1.0] }, AxpyTest{ - alpha: 3.0 - x: [2.0] - y: [-3.0] - want: [3.0] + alpha: 3.0 + x: [2.0] + y: [-3.0] + want: [3.0] want_rev: [3.0] }, AxpyTest{ - alpha: -3.0 - x: [2.0] - y: [-3.0] - want: [-9.0] + alpha: -3.0 + x: [2.0] + y: [-3.0] + want: [-9.0] want_rev: [-9.0] }, AxpyTest{ - alpha: 1.0 - x: [1.0, 5] - y: [2.0, -3] - want: [3.0, 2] + alpha: 1.0 + x: [1.0, 5] + y: [2.0, -3] + want: [3.0, 2] want_rev: [7.0, -2] }, AxpyTest{ - alpha: 1.0 - x: [2.0, 3, 4] - y: [-3.0, -2, -1] - want: [-1.0, 1, 3] + alpha: 1.0 + x: [2.0, 3, 4] + y: [-3.0, -2, -1] + want: [-1.0, 1, 3] want_rev: [1.0, 1, 1] }, AxpyTest{ - alpha: 0.0 - x: [0.0, 0, 1, 1, 2, -3, -4] - y: [0.0, 1, 0, 3, -4, 5, -6] - want: [0.0, 1, 0, 3, -4, 5, -6] + alpha: 0.0 + x: [0.0, 0, 1, 1, 2, -3, -4] + y: [0.0, 1, 0, 3, -4, 5, -6] + want: [0.0, 1, 0, 3, -4, 5, -6] want_rev: [0.0, 1, 0, 3, -4, 5, -6] }, AxpyTest{ - alpha: 1.0 - x: [0.0, 0, 1, 1, 2, -3, -4] - y: [0.0, 1, 0, 3, -4, 5, -6] - want: [0.0, 1, 1, 4, -2, 2, -10] + alpha: 1.0 + x: [0.0, 0, 1, 1, 2, -3, -4] + y: [0.0, 1, 0, 3, -4, 5, -6] + want: [0.0, 1, 1, 4, -2, 2, -10] want_rev: [-4.0, -2, 2, 4, -3, 5, -6] }, AxpyTest{ - alpha: 3.0 - x: [0.0, 0, 1, 1, 2, -3, -4] - y: [0.0, 1, 0, 3, -4, 5, -6] - want: [0.0, 1, 3, 6, 2, -4, -18] + alpha: 3.0 + x: [0.0, 0, 1, 1, 2, -3, -4] + y: [0.0, 1, 0, 3, -4, 5, -6] + want: [0.0, 1, 3, 6, 2, -4, -18] want_rev: [-12.0, -8, 6, 6, -1, 5, -6] }, AxpyTest{ - alpha: -3.0 - x: [0.0, 0, 1, 1, 2, -3, -4, 0, 0, 1, 1, 2, -3, -4] - y: [0.0, 1, 0, 3, -4, 5, -6, 0, 1, 0, 3, -4, 5, -6] - want: [0.0, 1, -3, 0, -10, 14, 6, 0, 1, -3, 0, -10, 14, 6] + alpha: -3.0 + x: [0.0, 0, 1, 1, 2, -3, -4, 0, 0, 1, 1, 2, -3, -4] + y: [0.0, 1, 0, 3, -4, 5, -6, 0, 1, 0, 3, -4, 5, -6] + want: [0.0, 1, -3, 0, -10, 14, 6, 0, 1, -3, 0, -10, 14, 6] want_rev: [12.0, 10, -6, 0, -7, 5, -6, 12, 10, -6, 0, -7, 5, -6] }, AxpyTest{ - alpha: -5.0 - x: [0.0, 0, 1, 1, 2, -3, -4, 5, 1, 2, -3, -4, 5] - y: [0.0, 1, 0, 3, -4, 5, -6, 7, 3, -4, 5, -6, 7] - want: [0.0, 1, -5, -2, -14, 20, 14, -18, -2, -14, 20, 14, -18] + alpha: -5.0 + x: [0.0, 0, 1, 1, 2, -3, -4, 5, 1, 2, -3, -4, 5] + y: [0.0, 1, 0, 3, -4, 5, -6, 7, 3, -4, 5, -6, 7] + want: [0.0, 1, -5, -2, -14, 20, 14, -18, -2, -14, 20, 14, -18] want_rev: [-25.0, 21, 15, -7, -9, -20, 14, 22, -7, -9, 0, -6, 7] }, ] @@ -98,7 +98,7 @@ struct AxpyTest { fn test_axpy_unitary() { x_gd_val, y_gd_val := -1.0, 1.5 - for test in float64.axpy_tests { + for test in axpy_tests { for align in align2 { xg_ln, yg_ln := 4 + align.x, 4 + align.y xg, yg := guard_vector(test.x, x_gd_val, xg_ln), guard_vector(test.y, y_gd_val, @@ -120,7 +120,7 @@ fn test_axpy_unitary() { fn test_axpy_unitary_to() { dst_gd_val, x_gd_val, y_gd_val := 1.0, -1.0, 1.5 - for test in float64.axpy_tests { + for test in axpy_tests { for align in align3 { dg_ln, xg_ln, yg_ln := 4 + align.dst, 4 + align.x, 4 + align.y dst_orig := []f64{len: test.x.len} @@ -148,7 +148,7 @@ fn test_axpy_inc() { x_gd_val, y_gd_val := -1.0, 1.5 gd_ln := 4 - for test in float64.axpy_tests { + for test in axpy_tests { n := test.x.len for inc in IncSet.new(-7, -4, -3, -2, -1, 1, 2, 3, 4, 7) { @@ -188,7 +188,7 @@ fn test_axpy_inc_to() { dst_gd_val, x_gd_val, y_gd_val := 1, -1.0, 1.5 gd_ln := 4 - for test in float64.axpy_tests { + for test in axpy_tests { n := test.x.len for inc in IncToSet.new(-7, -4, -3, -2, -1, 1, 2, 3, 4, 7) { diff --git a/float/float64/dot_test.v b/float/float64/dot_test.v index 5452c6dfe..8852c66f6 100644 --- a/float/float64/dot_test.v +++ b/float/float64/dot_test.v @@ -11,57 +11,57 @@ struct DotTest { const dot_tests = [ DotTest{ - x: [2.0] - y: [-3.0] - want: -6 + x: [2.0] + y: [-3.0] + want: -6 want_rev: -6 }, DotTest{ - x: [2.0, 3] - y: [-3.0, 4] - want: 6 + x: [2.0, 3] + y: [-3.0, 4] + want: 6 want_rev: -1 }, DotTest{ - x: [2.0, 3, -4] - y: [-3.0, 4, 5] - want: -14 + x: [2.0, 3, -4] + y: [-3.0, 4, 5] + want: -14 want_rev: 34 }, DotTest{ - x: [2.0, 3, -4, -5] - y: [-3.0, 4, 5, -6] - want: 16 + x: [2.0, 3, -4, -5] + y: [-3.0, 4, 5, -6] + want: 16 want_rev: 2 }, DotTest{ - x: [0.0, 2, 3, -4, -5] - y: [0.0, -3, 4, 5, -6] - want: 16 + x: [0.0, 2, 3, -4, -5] + y: [0.0, -3, 4, 5, -6] + want: 16 want_rev: 34 }, DotTest{ - x: [0.0, 0, 2, 3, -4, -5] - y: [0.0, 1, -3, 4, 5, -6] - want: 16 + x: [0.0, 0, 2, 3, -4, -5] + y: [0.0, 1, -3, 4, 5, -6] + want: 16 want_rev: -5 }, DotTest{ - x: [0.0, 0, 1, 1, 2, -3, -4] - y: [0.0, 1, 0, 3, -4, 5, -6] - want: 4 + x: [0.0, 0, 1, 1, 2, -3, -4] + y: [0.0, 1, 0, 3, -4, 5, -6] + want: 4 want_rev: -4 }, DotTest{ - x: [0.0, 0, 1, 1, 2, -3, -4, 5] - y: [0.0, 1, 0, 3, -4, 5, -6, 7] - want: 39 + x: [0.0, 0, 1, 1, 2, -3, -4, 5] + y: [0.0, 1, 0, 3, -4, 5, -6, 7] + want: 39 want_rev: 3 }, ] fn test_dot_unitary() { - for i, test in float64.dot_tests { + for i, test in dot_tests { x, x_front, x_back := new_guarded_vector(test.x, 1) y, y_front, y_back := new_guarded_vector(test.y, 1) got := dot_unitary(x, y) @@ -82,7 +82,7 @@ fn test_dot_unitary() { } fn test_dot_inc() { - for i, test in float64.dot_tests { + for i, test in dot_tests { for incx in [-7, -3, -2, -1, 1, 2, 3, 7] { for incy in [-7, -3, -2, -1, 1, 2, 3, 7] { n := test.x.len diff --git a/float/float64/ge_test.v b/float/float64/ge_test.v index 3f1653d99..f4f9c293c 100644 --- a/float/float64/ge_test.v +++ b/float/float64/ge_test.v @@ -4,27 +4,27 @@ import math const ge_tests = [// m x n ( kernels executed ) GeTest{ // 1 x 1 (1x1) - x: [2.0] - y: [4.4] - a: [10.0] + x: [2.0] + y: [4.4] + a: [10.0] want: [18.8] }, GeTest{ // 3 x 2 ( 2x2, 1x2 ) - x: [-2.0, -3, 0] - y: [-1.1, 5] - a: [1.3, 2.4, 2.6, 2.8, -1.3, -4.3] + x: [-2.0, -3, 0] + y: [-1.1, 5] + a: [1.3, 2.4, 2.6, 2.8, -1.3, -4.3] want: [3.5, -7.6, 5.9, -12.2, -1.3, -4.3] }, GeTest{ // 3 x 3 ( 2x2, 2x1, 1x2, 1x1 ) - x: [-2.0, 7, 12] - y: [-1.1, 0, 6] - a: [1.3, 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7] + x: [-2.0, 7, 12] + y: [-1.1, 0, 6] + a: [1.3, 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7] want: [3.5, 2.4, -8.5, -5.1, 2.8, 45.3, -14.5, -4.3, 62.3] }, GeTest{ // 5 x 3 ( 4x2, 4x1, 1x2, 1x1 ) - x: [-2.0, -3, 0, 1, 2] - y: [-1.1, 5, 0] - a: [1.3, 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7, 8, 9, -10, -12, -14, -6] + x: [-2.0, -3, 0, 1, 2] + y: [-1.1, 5, 0] + a: [1.3, 2.4, 3.5, 2.6, 2.8, 3.3, -1.3, -4.3, -9.7, 8, 9, -10, -12, -14, -6] want: [3.5, -7.6, 3.5, 5.9, -12.2, 3.3, -1.3, -4.3, -9.7, 6.9, 14, -10, -14.2, -4, -6] }, GeTest{ // 3 x 6 ( 2x4, 2x2, 1x4, 1x2 ) @@ -70,7 +70,7 @@ fn test_ger() { x_gd_val, y_gd_val, a_gd_val := -0.5, 1.5, 10 gd_ln := 4 - for test in float64.ge_tests { + for test in ge_tests { m := test.x.len n := test.y.len for align in align2 { diff --git a/float/float64/gemv_test.v b/float/float64/gemv_test.v index 34a383ee7..c45af6a4a 100644 --- a/float/float64/gemv_test.v +++ b/float/float64/gemv_test.v @@ -11,62 +11,62 @@ const dgemv_tests = [ y: [6.8] // (1x1) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0] - want_rev_x: [0.0] - want_rev_y: [0.0] + alpha: 0 + beta: 0 + want: [0.0] + want_rev_x: [0.0] + want_rev_y: [0.0] want_rev_xy: [0.0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [6.8] - want_rev_x: [6.8] - want_rev_y: [6.8] + alpha: 0 + beta: 1 + want: [6.8] + want_rev_x: [6.8] + want_rev_y: [6.8] want_rev_xy: [6.8] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [9.02] - want_rev_x: [9.02] - want_rev_y: [9.02] + alpha: 1 + beta: 0 + want: [9.02] + want_rev_x: [9.02] + want_rev_y: [9.02] want_rev_xy: [9.02] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [31.36] - want_rev_x: [31.36] - want_rev_y: [31.36] + alpha: 8 + beta: -6 + want: [31.36] + want_rev_x: [31.36] + want_rev_y: [31.36] want_rev_xy: [31.36] }] // (1x1) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0] - want_rev_x: [0.0] - want_rev_y: [0.0] + alpha: 0 + beta: 0 + want: [0.0] + want_rev_x: [0.0] + want_rev_y: [0.0] want_rev_xy: [0.0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [2.2] - want_rev_x: [2.2] - want_rev_y: [2.2] + alpha: 0 + beta: 1 + want: [2.2] + want_rev_x: [2.2] + want_rev_y: [2.2] want_rev_xy: [2.2] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [27.88] - want_rev_x: [27.88] - want_rev_y: [27.88] + alpha: 1 + beta: 0 + want: [27.88] + want_rev_x: [27.88] + want_rev_y: [27.88] want_rev_xy: [27.88] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [209.84] - want_rev_x: [209.84] - want_rev_y: [209.84] + alpha: 8 + beta: -6 + want: [209.84] + want_rev_x: [209.84] + want_rev_y: [209.84] want_rev_xy: [209.84] }] }, @@ -78,62 +78,62 @@ const dgemv_tests = [ y: [2.8, 1.71, 2.64] // (2x2, 1x2) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0] - want_rev_x: [0.0, 0, 0] - want_rev_y: [0.0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0] + want_rev_x: [0.0, 0, 0] + want_rev_y: [0.0, 0, 0] want_rev_xy: [0.0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [2.8, 1.71, 2.64] - want_rev_x: [2.8, 1.71, 2.64] - want_rev_y: [2.8, 1.71, 2.64] + alpha: 0 + beta: 1 + want: [2.8, 1.71, 2.64] + want_rev_x: [2.8, 1.71, 2.64] + want_rev_y: [2.8, 1.71, 2.64] want_rev_xy: [2.8, 1.71, 2.64] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [24.0346, 5.2524, 16.1664] - want_rev_x: [23.305, 5.5298, 16.3716] - want_rev_y: [16.1664, 5.2524, 24.0346] + alpha: 1 + beta: 0 + want: [24.0346, 5.2524, 16.1664] + want_rev_x: [23.305, 5.5298, 16.3716] + want_rev_y: [16.1664, 5.2524, 24.0346] want_rev_xy: [16.3716, 5.5298, 23.305] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [175.4768, 31.7592, 113.4912] - want_rev_x: [169.64, 33.9784, 115.1328] - want_rev_y: [112.5312, 31.7592, 176.4368] + alpha: 8 + beta: -6 + want: [175.4768, 31.7592, 113.4912] + want_rev_x: [169.64, 33.9784, 115.1328] + want_rev_y: [112.5312, 31.7592, 176.4368] want_rev_xy: [114.1728, 33.9784, 170.6] }] // (2x2) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0] - want_rev_x: [0.0, 0] - want_rev_y: [0.0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0] + want_rev_x: [0.0, 0] + want_rev_y: [0.0, 0] want_rev_xy: [0.0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [3.38, 3] - want_rev_x: [3.38, 3] - want_rev_y: [3.38, 3] + alpha: 0 + beta: 1 + want: [3.38, 3] + want_rev_x: [3.38, 3] + want_rev_y: [3.38, 3] want_rev_xy: [3.38, 3] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [19.916, 17.2139] - want_rev_x: [19.5336, 17.2251] - want_rev_y: [17.2139, 19.916] + alpha: 1 + beta: 0 + want: [19.916, 17.2139] + want_rev_x: [19.5336, 17.2251] + want_rev_y: [17.2139, 19.916] want_rev_xy: [17.2251, 19.5336] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [139.048, 119.7112] - want_rev_x: [135.9888, 119.8008] - want_rev_y: [117.4312, 141.328] + alpha: 8 + beta: -6 + want: [139.048, 119.7112] + want_rev_x: [135.9888, 119.8008] + want_rev_y: [117.4312, 141.328] want_rev_xy: [117.5208, 138.2688] }] }, @@ -145,62 +145,62 @@ const dgemv_tests = [ y: [0.24, 1.41, 3.45] // (2x2, 2x1, 1x2, 1x1) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0] - want_rev_x: [0.0, 0, 0] - want_rev_y: [0.0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0] + want_rev_x: [0.0, 0, 0] + want_rev_y: [0.0, 0, 0] want_rev_xy: [0.0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [0.24, 1.41, 3.45] - want_rev_x: [0.24, 1.41, 3.45] - want_rev_y: [0.24, 1.41, 3.45] + alpha: 0 + beta: 1 + want: [0.24, 1.41, 3.45] + want_rev_x: [0.24, 1.41, 3.45] + want_rev_y: [0.24, 1.41, 3.45] want_rev_xy: [0.24, 1.41, 3.45] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [33.8908, 24.0452, 16.7664] - want_rev_x: [33.4468, 18.0882, 8.8854] - want_rev_y: [16.7664, 24.0452, 33.8908] + alpha: 1 + beta: 0 + want: [33.8908, 24.0452, 16.7664] + want_rev_x: [33.4468, 18.0882, 8.8854] + want_rev_y: [16.7664, 24.0452, 33.8908] want_rev_xy: [8.8854, 18.0882, 33.4468] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [269.6864, 183.9016, 113.4312] - want_rev_x: [266.1344, 136.2456, 50.3832] - want_rev_y: [132.6912, 183.9016, 250.4264] + alpha: 8 + beta: -6 + want: [269.6864, 183.9016, 113.4312] + want_rev_x: [266.1344, 136.2456, 50.3832] + want_rev_y: [132.6912, 183.9016, 250.4264] want_rev_xy: [69.6432, 136.2456, 246.8744] }] // (2x2, 1x2, 2x1, 1x1) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0] - want_rev_x: [0.0, 0, 0] - want_rev_y: [0.0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0] + want_rev_x: [0.0, 0, 0] + want_rev_y: [0.0, 0, 0] want_rev_xy: [0.0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [4.82, 1.82, 1.12] - want_rev_x: [4.82, 1.82, 1.12] - want_rev_y: [4.82, 1.82, 1.12] + alpha: 0 + beta: 1 + want: [4.82, 1.82, 1.12] + want_rev_x: [4.82, 1.82, 1.12] + want_rev_y: [4.82, 1.82, 1.12] want_rev_xy: [4.82, 1.82, 1.12] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [15.8805, 8.9871, 6.2331] - want_rev_x: [21.6264, 16.4664, 18.4311] - want_rev_y: [6.2331, 8.9871, 15.8805] + alpha: 1 + beta: 0 + want: [15.8805, 8.9871, 6.2331] + want_rev_x: [21.6264, 16.4664, 18.4311] + want_rev_y: [6.2331, 8.9871, 15.8805] want_rev_xy: [18.4311, 16.4664, 21.6264] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [98.124, 60.9768, 43.1448] - want_rev_x: [144.0912, 120.8112, 140.7288] - want_rev_y: [20.9448, 60.9768, 120.324] + alpha: 8 + beta: -6 + want: [98.124, 60.9768, 43.1448] + want_rev_x: [144.0912, 120.8112, 140.7288] + want_rev_y: [20.9448, 60.9768, 120.324] want_rev_xy: [118.5288, 120.8112, 166.2912] }] }, @@ -212,62 +212,62 @@ const dgemv_tests = [ y: [7.0, 8, 9, 10, 11] //(4x2, 4x1, 1x2, 1x1) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0, 0, 0] - want_rev_x: [0.0, 0, 0, 0, 0] - want_rev_y: [0.0, 0, 0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0, 0, 0] + want_rev_x: [0.0, 0, 0, 0, 0] + want_rev_y: [0.0, 0, 0, 0, 0] want_rev_xy: [0.0, 0, 0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [7.0, 8, 9, 10, 11] - want_rev_x: [7.0, 8, 9, 10, 11] - want_rev_y: [7.0, 8, 9, 10, 11] + alpha: 0 + beta: 1 + want: [7.0, 8, 9, 10, 11] + want_rev_x: [7.0, 8, 9, 10, 11] + want_rev_y: [7.0, 8, 9, 10, 11] want_rev_xy: [7.0, 8, 9, 10, 11] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [40.8, 43.9, 33, 9, 28] - want_rev_x: [32.8, 44.9, 47, 7, 36] - want_rev_y: [28.0, 9, 33, 43.9, 40.8] + alpha: 1 + beta: 0 + want: [40.8, 43.9, 33, 9, 28] + want_rev_x: [32.8, 44.9, 47, 7, 36] + want_rev_y: [28.0, 9, 33, 43.9, 40.8] want_rev_xy: [36.0, 7, 47, 44.9, 32.8] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [284.4, 303.2, 210, 12, 158] - want_rev_x: [220.4, 311.2, 322, -4, 222] - want_rev_y: [182.0, 24, 210, 291.2, 260.4] + alpha: 8 + beta: -6 + want: [284.4, 303.2, 210, 12, 158] + want_rev_x: [220.4, 311.2, 322, -4, 222] + want_rev_y: [182.0, 24, 210, 291.2, 260.4] want_rev_xy: [246.0, 8, 322, 299.2, 196.4] }] //( 2x4, 1x4, 2x1, 1x1) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0] - want_rev_x: [0.0, 0, 0] - want_rev_y: [0.0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0] + want_rev_x: [0.0, 0, 0] + want_rev_y: [0.0, 0, 0] want_rev_xy: [0.0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [1.0, 2, 3] - want_rev_x: [1.0, 2, 3] - want_rev_y: [1.0, 2, 3] + alpha: 0 + beta: 1 + want: [1.0, 2, 3] + want_rev_x: [1.0, 2, 3] + want_rev_y: [1.0, 2, 3] want_rev_xy: [1.0, 2, 3] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [304.5, 166.4, 231.5] - want_rev_x: [302.1, 188.2, 258.1] - want_rev_y: [231.5, 166.4, 304.5] + alpha: 1 + beta: 0 + want: [304.5, 166.4, 231.5] + want_rev_x: [302.1, 188.2, 258.1] + want_rev_y: [231.5, 166.4, 304.5] want_rev_xy: [258.1, 188.2, 302.1] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [2430.0, 1319.2, 1834] - want_rev_x: [2410.8, 1493.6, 2046.8] - want_rev_y: [1846.0, 1319.2, 2418] + alpha: 8 + beta: -6 + want: [2430.0, 1319.2, 1834] + want_rev_x: [2410.8, 1493.6, 2046.8] + want_rev_y: [1846.0, 1319.2, 2418] want_rev_xy: [2058.8, 1493.6, 2398.8] }] }, @@ -279,62 +279,62 @@ const dgemv_tests = [ y: [2.46, 2.22, 4.75] // (2x4, 2x1, 1x4, 1x1) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0] - want_rev_x: [0.0, 0, 0] - want_rev_y: [0.0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0] + want_rev_x: [0.0, 0, 0] + want_rev_y: [0.0, 0, 0] want_rev_xy: [0.0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [2.46, 2.22, 4.75] - want_rev_x: [2.46, 2.22, 4.75] - want_rev_y: [2.46, 2.22, 4.75] + alpha: 0 + beta: 1 + want: [2.46, 2.22, 4.75] + want_rev_x: [2.46, 2.22, 4.75] + want_rev_y: [2.46, 2.22, 4.75] want_rev_xy: [2.46, 2.22, 4.75] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [37.8098, 28.8939, 22.5949] - want_rev_x: [32.8088, 27.5978, 25.8927] - want_rev_y: [22.5949, 28.8939, 37.8098] + alpha: 1 + beta: 0 + want: [37.8098, 28.8939, 22.5949] + want_rev_x: [32.8088, 27.5978, 25.8927] + want_rev_y: [22.5949, 28.8939, 37.8098] want_rev_xy: [25.8927, 27.5978, 32.8088] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [287.7184, 217.8312, 152.2592] - want_rev_x: [247.7104, 207.4624, 178.6416] - want_rev_y: [165.9992, 217.8312, 273.9784] + alpha: 8 + beta: -6 + want: [287.7184, 217.8312, 152.2592] + want_rev_x: [247.7104, 207.4624, 178.6416] + want_rev_y: [165.9992, 217.8312, 273.9784] want_rev_xy: [192.3816, 207.4624, 233.9704] }] // (4x2, 1x2, 4x1, 1x1) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0, 0, 0] - want_rev_x: [0.0, 0, 0, 0, 0] - want_rev_y: [0.0, 0, 0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0, 0, 0] + want_rev_x: [0.0, 0, 0, 0, 0] + want_rev_y: [0.0, 0, 0, 0, 0] want_rev_xy: [0.0, 0, 0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [2.34, 2.82, 4.73, 0.22, 3.91] - want_rev_x: [2.34, 2.82, 4.73, 0.22, 3.91] - want_rev_y: [2.34, 2.82, 4.73, 0.22, 3.91] + alpha: 0 + beta: 1 + want: [2.34, 2.82, 4.73, 0.22, 3.91] + want_rev_x: [2.34, 2.82, 4.73, 0.22, 3.91] + want_rev_y: [2.34, 2.82, 4.73, 0.22, 3.91] want_rev_xy: [2.34, 2.82, 4.73, 0.22, 3.91] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [16.5211, 9.8878, 30.2114, 8.3156, 13.6087] - want_rev_x: [17.0936, 13.9182, 30.5778, 7.8576, 18.8528] - want_rev_y: [13.6087, 8.3156, 30.2114, 9.8878, 16.5211] + alpha: 1 + beta: 0 + want: [16.5211, 9.8878, 30.2114, 8.3156, 13.6087] + want_rev_x: [17.0936, 13.9182, 30.5778, 7.8576, 18.8528] + want_rev_y: [13.6087, 8.3156, 30.2114, 9.8878, 16.5211] want_rev_xy: [18.8528, 7.8576, 30.5778, 13.9182, 17.0936] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [118.1288, 62.1824, 213.3112, 65.2048, 85.4096] - want_rev_x: [122.7088, 94.4256, 216.2424, 61.5408, 127.3624] - want_rev_y: [94.8296, 49.6048, 213.3112, 77.7824, 108.7088] + alpha: 8 + beta: -6 + want: [118.1288, 62.1824, 213.3112, 65.2048, 85.4096] + want_rev_x: [122.7088, 94.4256, 216.2424, 61.5408, 127.3624] + want_rev_y: [94.8296, 49.6048, 213.3112, 77.7824, 108.7088] want_rev_xy: [136.7824, 45.9408, 216.2424, 110.0256, 113.2888] }] }, @@ -348,62 +348,62 @@ const dgemv_tests = [ y: [3.2, 4.4, 5.0, 4.3, 4.1, 1.4, 0.2] // (4x4, 4x2, 4x1, 2x4, 2x2, 2x1, 1x4, 1x2, 1x1) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0, math.nan(), 0, 0, 0] - want_rev_x: [0.0, 0, 0, math.nan(), 0, 0, 0] - want_rev_y: [0.0, 0, 0, math.nan(), 0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0, math.nan(), 0, 0, 0] + want_rev_x: [0.0, 0, 0, math.nan(), 0, 0, 0] + want_rev_y: [0.0, 0, 0, math.nan(), 0, 0, 0] want_rev_xy: [0.0, 0, 0, math.nan(), 0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] - want_rev_x: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] - want_rev_y: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] + alpha: 0 + beta: 1 + want: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] + want_rev_x: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] + want_rev_y: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] want_rev_xy: [3.2, 4.4, 5.0, math.nan(), 4.1, 1.4, 0.2] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [13.43, 11.82, 22.78, math.nan(), 21.93, 18.19, 15.39] - want_rev_x: [19.94, 14.21, 23.95, math.nan(), 19.29, 14.81, 18.52] - want_rev_y: [15.39, 18.19, 21.93, math.nan(), 22.78, 11.82, 13.43] + alpha: 1 + beta: 0 + want: [13.43, 11.82, 22.78, math.nan(), 21.93, 18.19, 15.39] + want_rev_x: [19.94, 14.21, 23.95, math.nan(), 19.29, 14.81, 18.52] + want_rev_y: [15.39, 18.19, 21.93, math.nan(), 22.78, 11.82, 13.43] want_rev_xy: [18.52, 14.81, 19.29, math.nan(), 23.95, 14.21, 19.94] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [88.24, 68.16, 152.24, math.nan(), 150.84, 137.12, 121.92] - want_rev_x: [140.32, 87.28, 161.6, math.nan(), 129.72, 110.08, 146.96] - want_rev_y: [103.92, 119.12, 145.44, math.nan(), 157.64, 86.16, 106.24] + alpha: 8 + beta: -6 + want: [88.24, 68.16, 152.24, math.nan(), 150.84, 137.12, 121.92] + want_rev_x: [140.32, 87.28, 161.6, math.nan(), 129.72, 110.08, 146.96] + want_rev_y: [103.92, 119.12, 145.44, math.nan(), 157.64, 86.16, 106.24] want_rev_xy: [128.96, 92.08, 124.32, math.nan(), 167.0, 105.28, 158.32] }] // (4x4, 2x4, 1x4, 4x2, 2x2, 1x2, 4x1, 2x1, 1x1) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0, 0, math.nan(), 0, 0] - want_rev_x: [0.0, 0, 0, 0, math.nan(), 0, 0] - want_rev_y: [0.0, 0, math.nan(), 0, 0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0, 0, math.nan(), 0, 0] + want_rev_x: [0.0, 0, 0, 0, math.nan(), 0, 0] + want_rev_y: [0.0, 0, math.nan(), 0, 0, 0, 0] want_rev_xy: [0.0, 0, math.nan(), 0, 0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [0.4, 2.8, 3.5, 0.3, math.nan(), 2.5, 3.1] - want_rev_x: [0.4, 2.8, 3.5, 0.3, math.nan(), 2.5, 3.1] - want_rev_y: [0.4, 2.8, math.nan(), 0.3, 0.6, 2.5, 3.1] + alpha: 0 + beta: 1 + want: [0.4, 2.8, 3.5, 0.3, math.nan(), 2.5, 3.1] + want_rev_x: [0.4, 2.8, 3.5, 0.3, math.nan(), 2.5, 3.1] + want_rev_y: [0.4, 2.8, math.nan(), 0.3, 0.6, 2.5, 3.1] want_rev_xy: [0.4, 2.8, math.nan(), 0.3, 0.6, 2.5, 3.1] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [39.22, 38.86, 38.61, 39.55, math.nan(), 27.53, 25.71] - want_rev_x: [40.69, 40.33, 42.06, 41.92, math.nan(), 24.98, 30.63] - want_rev_y: [25.71, 27.53, math.nan(), 39.55, 38.61, 38.86, 39.22] + alpha: 1 + beta: 0 + want: [39.22, 38.86, 38.61, 39.55, math.nan(), 27.53, 25.71] + want_rev_x: [40.69, 40.33, 42.06, 41.92, math.nan(), 24.98, 30.63] + want_rev_y: [25.71, 27.53, math.nan(), 39.55, 38.61, 38.86, 39.22] want_rev_xy: [30.63, 24.98, math.nan(), 41.92, 42.06, 40.33, 40.69] }, DgemvSubcase{ - alpha: 8 - beta: -6 - want: [311.36, 294.08, 287.88, 314.6, math.nan(), 205.24, 187.08] - want_rev_x: [323.12, 305.84, 315.48, 333.56, math.nan(), 184.84, 226.44] - want_rev_y: [203.28, 203.44, math.nan(), 314.6, 305.28, 295.88, 295.16] + alpha: 8 + beta: -6 + want: [311.36, 294.08, 287.88, 314.6, math.nan(), 205.24, 187.08] + want_rev_x: [323.12, 305.84, 315.48, 333.56, math.nan(), 184.84, 226.44] + want_rev_y: [203.28, 203.44, math.nan(), 314.6, 305.28, 295.88, 295.16] want_rev_xy: [242.64, 183.04, math.nan(), 333.56, 332.88, 307.64, 306.92] }] }, @@ -422,31 +422,32 @@ const dgemv_tests = [ y: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] // (4x4, 4x2, 4x1, 2x4, 2x2, 2x1, 1x4, 1x2, 1x1) no_trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - want_rev_x: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - want_rev_y: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + want_rev_x: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + want_rev_y: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] want_rev_xy: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] - want_rev_x: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] - want_rev_y: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] + alpha: 0 + beta: 1 + want: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] + want_rev_x: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] + want_rev_y: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] want_rev_xy: [3.8, 3.4, 1.6, 4.8, 4.3, 0.5, 2.0, 2.5, 1.5, 2.8, 3.9] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [32.71, 38.93, 33.55, 45.46, 39.24, 38.41, 46.23, 25.78, 37.33, 37.42, 24.63] + alpha: 1 + beta: 0 + want: [32.71, 38.93, 33.55, 45.46, 39.24, 38.41, 46.23, 25.78, 37.33, 37.42, + 24.63] want_rev_x: [39.82, 43.78, 37.73, 41.19, 40.17, 44.41, 42.75, 28.14, 35.6, 41.25, 23.9] want_rev_y: [24.63, 37.42, 37.33, 25.78, 46.23, 38.41, 39.24, 45.46, 33.55, 38.93, 32.71] want_rev_xy: [23.9, 41.25, 35.6, 28.14, 42.75, 44.41, 40.17, 41.19, 37.73, 43.78, 39.82] }, DgemvSubcase{ alpha: 8 - beta: -6 - want: [238.88, 291.04, 258.8, 334.88, 288.12, 304.28, 357.84, 191.24, 289.64, 282.56, + beta: -6 + want: [238.88, 291.04, 258.8, 334.88, 288.12, 304.28, 357.84, 191.24, 289.64, 282.56, 173.64] want_rev_x: [295.76, 329.84, 292.24, 300.72, 295.56, 352.28, 330.0, 210.12, 275.8, 313.2, 167.8] @@ -457,23 +458,24 @@ const dgemv_tests = [ }] // (4x4, 2x4, 1x4, 4x2, 2x2, 1x2, 4x1, 2x1, 1x1) trans: [DgemvSubcase{ - alpha: 0 - beta: 0 - want: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - want_rev_x: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] - want_rev_y: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + alpha: 0 + beta: 0 + want: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + want_rev_x: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] + want_rev_y: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] want_rev_xy: [0.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, DgemvSubcase{ - alpha: 0 - beta: 1 - want: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] - want_rev_x: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] - want_rev_y: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] + alpha: 0 + beta: 1 + want: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] + want_rev_x: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] + want_rev_y: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] want_rev_xy: [2.5, 1.2, 0.8, 2.9, 3.4, 1.8, 4.6, 3.3, 3.8, 0.9, 1.1] }, DgemvSubcase{ - alpha: 1 - beta: 0 - want: [37.07, 55.58, 46.05, 47.34, 33.88, 54.19, 50.85, 39.31, 31.29, 55.31, 46.98] + alpha: 1 + beta: 0 + want: [37.07, 55.58, 46.05, 47.34, 33.88, 54.19, 50.85, 39.31, 31.29, 55.31, + 46.98] want_rev_x: [38.11, 63.38, 46.44, 40.04, 34.63, 59.27, 50.13, 35.45, 28.26, 51.64, 46.22] want_rev_y: [46.98, 55.31, 31.29, 39.31, 50.85, 54.19, 33.88, 47.34, 46.05, 55.58, @@ -482,8 +484,8 @@ const dgemv_tests = [ 38.11] }, DgemvSubcase{ alpha: 8 - beta: -6 - want: [281.56, 437.44, 363.6, 361.32, 250.64, 422.72, 379.2, 294.68, 227.52, 437.08, + beta: -6 + want: [281.56, 437.44, 363.6, 361.32, 250.64, 422.72, 379.2, 294.68, 227.52, 437.08, 369.24] want_rev_x: [289.88, 499.84, 366.72, 302.92, 256.64, 463.36, 373.44, 263.8, 203.28, 407.72, 363.16] @@ -516,7 +518,7 @@ struct DgemvSubcase { } fn test_gemv() { - for mut test in float64.dgemv_tests { + for mut test in dgemv_tests { for case in test.no_trans { dgemvcomp(mut test, false, case) } diff --git a/float/float64/l2norm_test.v b/float/float64/l2norm_test.v index 478b3a71f..053227dde 100644 --- a/float/float64/l2norm_test.v +++ b/float/float64/l2norm_test.v @@ -24,35 +24,35 @@ fn test_l2_norm_unitary() { l2_norm_unitary_tests := [ L2NormTest{ want: 0.0 - x: []f64{} + x: []f64{} }, L2NormTest{ want: 2.0 - x: [2.0] + x: [2.0] }, L2NormTest{ want: 3.7416573867739413 - x: [1.0, 2, 3] + x: [1.0, 2, 3] }, L2NormTest{ want: 3.7416573867739413 - x: [-1.0, -2, -3] + x: [-1.0, -2, -3] }, L2NormTest{ want: math.nan() - x: [math.nan()] + x: [math.nan()] }, L2NormTest{ want: math.nan() - x: [1.0, math.inf(1), 3, nanwith(25), 5] + x: [1.0, math.inf(1), 3, nanwith(25), 5] }, L2NormTest{ want: 17.88854381999832 - x: [8.0, -8, 8, -8, 8] + x: [8.0, -8, 8, -8, 8] }, L2NormTest{ want: 2.23606797749979 - x: [0.0, 1, 0, -1, 0, 1, 0, -1, 0, 1] + x: [0.0, 1, 0, -1, 0, 1, 0, -1, 0, 1] }, ] @@ -73,39 +73,39 @@ fn test_l2_norm_inc() { l2_norm_inc_tests := [ L2NormTest{ - inc: 2 + inc: 2 want: 0.0 - x: []f64{} + x: []f64{} }, L2NormTest{ - inc: 3 + inc: 3 want: 2.0 - x: [2.0] + x: [2.0] }, L2NormTest{ - inc: 10 + inc: 10 want: 3.7416573867739413 - x: [1.0, 2, 3] + x: [1.0, 2, 3] }, L2NormTest{ - inc: 5 + inc: 5 want: 3.7416573867739413 - x: [-1.0, -2, -3] + x: [-1.0, -2, -3] }, L2NormTest{ - inc: 3 + inc: 3 want: math.nan() - x: [math.nan()] + x: [math.nan()] }, L2NormTest{ - inc: 15 + inc: 15 want: 17.88854381999832 - x: [8.0, -8, 8, -8, 8] + x: [8.0, -8, 8, -8, 8] }, L2NormTest{ - inc: 1 + inc: 1 want: 2.23606797749979 - x: [0.0, 1, 0, -1, 0, 1, 0, -1, 0, 1] + x: [0.0, 1, 0, -1, 0, 1, 0, -1, 0, 1] }, ] @@ -127,38 +127,38 @@ fn test_l2_distance_unitary() { l2_distance_unitary_tests := [ L2NormTest{ want: 0.0 - x: []f64{} - y: []f64{} + x: []f64{} + y: []f64{} }, L2NormTest{ want: 2.0 - x: [3.0] - y: [1.0] + x: [3.0] + y: [1.0] }, L2NormTest{ want: 3.7416573867739413 - x: [2.0, 4, 6] - y: [1.0, 2, 3] + x: [2.0, 4, 6] + y: [1.0, 2, 3] }, L2NormTest{ want: 3.7416573867739413 - x: [1.0, 2, 3] - y: [2.0, 4, 6] + x: [1.0, 2, 3] + y: [2.0, 4, 6] }, L2NormTest{ want: math.nan() - x: [math.nan()] - y: [0.0] + x: [math.nan()] + y: [0.0] }, L2NormTest{ want: 17.88854381999832 - x: [9.0, -9, 9, -9, 9] - y: [1.0, -1, 1, -1, 1] + x: [9.0, -9, 9, -9, 9] + y: [1.0, -1, 1, -1, 1] }, L2NormTest{ want: 2.23606797749979 - x: [0.0, 1, 0, -1, 0, 1, 0, -1, 0, 1] - y: [0.0, 2, 0, -2, 0, 2, 0, -2, 0, 2] + x: [0.0, 1, 0, -1, 0, 1, 0, -1, 0, 1] + y: [0.0, 2, 0, -2, 0, 2, 0, -2, 0, 2] }, ] diff --git a/float/float64/scal_test.v b/float/float64/scal_test.v index fbeba8bba..2c1fba388 100644 --- a/float/float64/scal_test.v +++ b/float/float64/scal_test.v @@ -11,65 +11,65 @@ struct ScalTest { const scal_tests = [ ScalTest{ alpha: 0.0 - x: []f64{} - want: []f64{} + x: []f64{} + want: []f64{} }, ScalTest{ alpha: 0.0 - x: [1.0] - want: [0.0] + x: [1.0] + want: [0.0] }, ScalTest{ alpha: 1.0 - x: [1.0] - want: [1.0] + x: [1.0] + want: [1.0] }, ScalTest{ alpha: 2.0 - x: [1.0, -2] - want: [2.0, -4] + x: [1.0, -2] + want: [2.0, -4] }, ScalTest{ alpha: 2.0 - x: [1.0, -2, 3] - want: [2.0, -4, 6] + x: [1.0, -2, 3] + want: [2.0, -4, 6] }, ScalTest{ alpha: 2.0 - x: [1.0, -2, 3, 4] - want: [2.0, -4, 6, 8] + x: [1.0, -2, 3, 4] + want: [2.0, -4, 6, 8] }, ScalTest{ alpha: 2.0 - x: [1.0, -2, 3, 4, -5] - want: [2.0, -4, 6, 8, -10] + x: [1.0, -2, 3, 4, -5] + want: [2.0, -4, 6, 8, -10] }, ScalTest{ alpha: 2.0 - x: [0.0, 1, -2, 3, 4, -5, 6, -7] - want: [0.0, 2, -4, 6, 8, -10, 12, -14] + x: [0.0, 1, -2, 3, 4, -5, 6, -7] + want: [0.0, 2, -4, 6, 8, -10, 12, -14] }, ScalTest{ alpha: 2.0 - x: [0.0, 1, -2, 3, 4, -5, 6, -7, 8] - want: [0.0, 2, -4, 6, 8, -10, 12, -14, 16] + x: [0.0, 1, -2, 3, 4, -5, 6, -7, 8] + want: [0.0, 2, -4, 6, 8, -10, 12, -14, 16] }, ScalTest{ alpha: 2.0 - x: [0.0, 1, -2, 3, 4, -5, 6, -7, 8, 9] - want: [0.0, 2, -4, 6, 8, -10, 12, -14, 16, 18] + x: [0.0, 1, -2, 3, 4, -5, 6, -7, 8, 9] + want: [0.0, 2, -4, 6, 8, -10, 12, -14, 16, 18] }, ScalTest{ alpha: 3.0 - x: [0.0, 1, -2, 3, 4, -5, 6, -7, 8, 9, 12] - want: [0.0, 3, -6, 9, 12, -15, 18, -21, 24, 27, 36] + x: [0.0, 1, -2, 3, 4, -5, 6, -7, 8, 9, 12] + want: [0.0, 3, -6, 9, 12, -15, 18, -21, 24, 27, 36] }, ] fn test_scal_unitary() { x_gd_val := -0.5 - for test in float64.scal_tests { + for test in scal_tests { for align in align1 { xg_ln := 4 + align xg := guard_vector(test.x, x_gd_val, xg_ln) @@ -90,7 +90,7 @@ fn test_scal_unitary_to() { rand.seed([u32(42), u32(42)]) x_gd_val, dst_gd_val := -1.0, 0.5 - for test in float64.scal_tests { + for test in scal_tests { n := test.x.len for align in align2 { xg_ln, dg_ln := 4 + align.x, 4 + align.y @@ -116,7 +116,7 @@ fn test_scal_inc() { x_gd_val := -0.5 gd_ln := 4 - for test in float64.scal_tests { + for test in scal_tests { n := test.x.len for incx in [1, 2, 3, 4, 7, 10] { xg := guard_inc_vector(test.x, x_gd_val, incx, gd_ln) @@ -138,7 +138,7 @@ fn test_scal_inc_to() { x_gd_val, dst_gd_val := -1.0, 0.5 gd_ln := 4 - for test in float64.scal_tests { + for test in scal_tests { n := test.x.len for inc in IncSet.new(1, 2, 3, 4, 7, 10) { xg := guard_inc_vector(test.x, x_gd_val, inc.x, gd_ln) diff --git a/fun/bessel.v b/fun/bessel.v index d0a8dc3d2..48ca035c6 100644 --- a/fun/bessel.v +++ b/fun/bessel.v @@ -136,17 +136,17 @@ pub fn bessel_j0(x_ f64) f64 { return z // x| >= 2.0 } - if x < fun.two_m13 { + if x < two_m13 { // |x| < ~1.2207e-4 - if x < fun.two_m27 { + if x < two_m27 { return 1.0 // x| < ~7.4506e-9 } return 1.0 - 0.25 * x * x // ~7.4506e-9 < |x| < ~1.2207e-4 } z := x * x - r := z * (fun.j0r02 + z * (fun.j0r03 + z * (fun.j0r04 + z * fun.j0r05))) - s := 1.0 + z * (fun.j0s01 + z * (fun.j0s02 + z * (fun.j0s03 + z * fun.j0s04))) + r := z * (j0r02 + z * (j0r03 + z * (j0r04 + z * j0r05))) + s := 1.0 + z * (j0s01 + z * (j0s02 + z * (j0s03 + z * j0s04))) if x < 1.0 { return 1.0 + z * (-0.25 + (r / s)) // x| < 1.00 @@ -202,13 +202,13 @@ pub fn bessel_j1(x_ f64) f64 { } return z } - if x < fun.two_m27 { + if x < two_m27 { // |x|<2**-27 return f64(0.5) * x // inexact if x!=0 necessary } mut z := x * x - mut r := z * (fun.j1r00 + z * (fun.j1r01 + z * (fun.j1r02 + z * fun.j1r03))) - s := 1.0 + z * (fun.j1s01 + z * (fun.j1s02 + z * (fun.j1s03 + z * (fun.j1s04 + z * fun.j1s05)))) + mut r := z * (j1r00 + z * (j1r01 + z * (j1r02 + z * j1r03))) + s := 1.0 + z * (j1s01 + z * (j1s02 + z * (j1s03 + z * (j1s04 + z * j1s05)))) r *= x z = f64(0.5) * x + r / s if sign { @@ -298,7 +298,7 @@ pub fn bessel_jn(n_ int, x_ f64) f64 { } } } else { - if x < fun.two_m29 { + if x < two_m29 { // x < 2**-29 // x is tiny, return the first Taylor expansion of J(n,x) // J(n,x) = 1/n!*(x/2)**n - ... @@ -461,14 +461,13 @@ pub fn bessel_y0(x f64) f64 { return z // x| >= 2.0 } - if x <= fun.two_m27 { - return fun.y0u00 + (f64(2.0) / math.pi) * math.log(x) + if x <= two_m27 { + return y0u00 + (f64(2.0) / math.pi) * math.log(x) // x| < ~7.4506e-9 } z := x * x - u := fun.y0u00 + z * (fun.y0u01 + z * (fun.y0u02 + z * (fun.y0u03 + z * (fun.y0u04 + - z * (fun.y0u05 + z * fun.y0u06))))) - v := 1.0 + z * (fun.y0v01 + z * (fun.y0v02 + z * (fun.y0v03 + z * fun.y0v04))) + u := y0u00 + z * (y0u01 + z * (y0u02 + z * (y0u03 + z * (y0u04 + z * (y0u05 + z * y0u06))))) + v := 1.0 + z * (y0v01 + z * (y0v02 + z * (y0v03 + z * y0v04))) return u / v + (f64(2.0) / math.pi) * bessel_j0(x) * math.log(x) // ~7.4506e-9 < |x| < 2.0 } @@ -523,13 +522,13 @@ pub fn bessel_y1(x f64) f64 { } return z } - if x <= fun.two_m54 { + if x <= two_m54 { // x < 2**-54 return -(f64(2.0) / math.pi) / x } z := x * x - u := fun.y1u00 + z * (fun.y1u01 + z * (fun.y1u02 + z * (fun.y1u03 + z * fun.y1u04))) - v := 1.0 + z * (fun.y1v00 + z * (fun.y1v01 + z * (fun.y1v02 + z * (fun.y1v03 + z * fun.y1v04)))) + u := y1u00 + z * (y1u01 + z * (y1u02 + z * (y1u03 + z * y1u04))) + v := 1.0 + z * (y1v00 + z * (y1v01 + z * (y1v02 + z * (y1v03 + z * y1v04)))) return x * (u / v) + (2.0 / math.pi) * (bessel_j1(x) * math.log(x) - 1.0 / x) } diff --git a/fun/erf.v b/fun/erf.v index a0f9dcd04..d19fb1087 100644 --- a/fun/erf.v +++ b/fun/erf.v @@ -238,14 +238,14 @@ pub fn erf(x_ f64) f64 { if x < small { // x| < 2**-28 if x < very_tiny { - temp = 0.125 * (8.0 * x + fun.efx8 * x) // avoid underflow + temp = 0.125 * (8.0 * x + efx8 * x) // avoid underflow } else { - temp = x + fun.efx * x + temp = x + efx * x } } else { z := x * x - r := fun.pp0 + z * (fun.pp1 + z * (fun.pp2 + z * (fun.pp3 + z * fun.pp4))) - s_ := 1.0 + z * (fun.qq1 + z * (fun.qq2 + z * (fun.qq3 + z * (fun.qq4 + z * fun.qq5)))) + r := pp0 + z * (pp1 + z * (pp2 + z * (pp3 + z * pp4))) + s_ := 1.0 + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))) y := r / s_ temp = x + x * y } @@ -256,14 +256,12 @@ pub fn erf(x_ f64) f64 { } if x < 1.25 { // 0.84375 <= |x| < 1.25 s_ := x - 1 - p := fun.pa0 + s_ * (fun.pa1 + s_ * (fun.pa2 + s_ * (fun.pa3 + s_ * (fun.pa4 + - s_ * (fun.pa5 + s_ * fun.pa6))))) - q := 1.0 + s_ * (fun.qa1 + s_ * (fun.qa2 + s_ * (fun.qa3 + s_ * (fun.qa4 + s_ * (fun.qa5 + - s_ * fun.qa6))))) + p := pa0 + s_ * (pa1 + s_ * (pa2 + s_ * (pa3 + s_ * (pa4 + s_ * (pa5 + s_ * pa6))))) + q := 1.0 + s_ * (qa1 + s_ * (qa2 + s_ * (qa3 + s_ * (qa4 + s_ * (qa5 + s_ * qa6))))) if sign { - return -fun.erx - p / q + return -erx - p / q } - return fun.erx + p / q + return erx + p / q } if x >= 6 { // inf > |x| >= 6 if sign { @@ -276,16 +274,15 @@ pub fn erf(x_ f64) f64 { mut s := 0.0 if x < 1.0 / 0.35 { // x| < 1 / 0.35 ~ 2.857143 - r = fun.ra0 + s_ * (fun.ra1 + s_ * (fun.ra2 + s_ * (fun.ra3 + s_ * (fun.ra4 + - s_ * (fun.ra5 + s_ * (fun.ra6 + s_ * fun.ra7)))))) - s = 1.0 + s_ * (fun.sa1 + s_ * (fun.sa2 + s_ * (fun.sa3 + s_ * (fun.sa4 + s_ * (fun.sa5 + - s_ * (fun.sa6 + s_ * (fun.sa7 + s_ * fun.sa8))))))) + r = ra0 + s_ * (ra1 + s_ * (ra2 + s_ * (ra3 + s_ * (ra4 + s_ * (ra5 + s_ * (ra6 + + s_ * ra7)))))) + s = 1.0 + s_ * (sa1 + s_ * (sa2 + s_ * (sa3 + s_ * (sa4 + s_ * (sa5 + s_ * (sa6 + + s_ * (sa7 + s_ * sa8))))))) } else { // x| >= 1 / 0.35 ~ 2.857143 - r = fun.rb0 + s_ * (fun.rb1 + s_ * (fun.rb2 + s_ * (fun.rb3 + s_ * (fun.rb4 + - s_ * (fun.rb5 + s_ * fun.rb6))))) - s = 1.0 + s_ * (fun.sb1 + s_ * (fun.sb2 + s_ * (fun.sb3 + s_ * (fun.sb4 + s_ * (fun.sb5 + - s_ * (fun.sb6 + s_ * fun.sb7)))))) + r = rb0 + s_ * (rb1 + s_ * (rb2 + s_ * (rb3 + s_ * (rb4 + s_ * (rb5 + s_ * rb6))))) + s = 1.0 + s_ * (sb1 + s_ * (sb2 + s_ * (sb3 + s_ * (sb4 + s_ * (sb5 + s_ * (sb6 + + s_ * sb7)))))) } z := math.f64_from_bits(math.f64_bits(x) & 0xffffffff00000000) // pseudo-single (20-bit) precision x r_ := math.exp(-z * z - 0.5625) * math.exp((z - x) * (z + x) + r / s) @@ -327,8 +324,8 @@ pub fn erfc(x_ f64) f64 { temp = x } else { z := x * x - r := fun.pp0 + z * (fun.pp1 + z * (fun.pp2 + z * (fun.pp3 + z * fun.pp4))) - s_ := 1.0 + z * (fun.qq1 + z * (fun.qq2 + z * (fun.qq3 + z * (fun.qq4 + z * fun.qq5)))) + r := pp0 + z * (pp1 + z * (pp2 + z * (pp3 + z * pp4))) + s_ := 1.0 + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))) y := r / s_ if x < 0.25 { // x| < 1.0/4 @@ -344,14 +341,12 @@ pub fn erfc(x_ f64) f64 { } if x < 1.25 { // 0.84375 <= |x| < 1.25 s_ := x - 1 - p := fun.pa0 + s_ * (fun.pa1 + s_ * (fun.pa2 + s_ * (fun.pa3 + s_ * (fun.pa4 + - s_ * (fun.pa5 + s_ * fun.pa6))))) - q := 1.0 + s_ * (fun.qa1 + s_ * (fun.qa2 + s_ * (fun.qa3 + s_ * (fun.qa4 + s_ * (fun.qa5 + - s_ * fun.qa6))))) + p := pa0 + s_ * (pa1 + s_ * (pa2 + s_ * (pa3 + s_ * (pa4 + s_ * (pa5 + s_ * pa6))))) + q := 1.0 + s_ * (qa1 + s_ * (qa2 + s_ * (qa3 + s_ * (qa4 + s_ * (qa5 + s_ * qa6))))) if sign { - return 1.0 + fun.erx + p / q + return 1.0 + erx + p / q } - return 1.0 - fun.erx - p / q + return 1.0 - erx - p / q } if x < 28 { // x| < 28 @@ -360,19 +355,18 @@ pub fn erfc(x_ f64) f64 { mut s := 0.0 if x < 1.0 / 0.35 { // x| < 1 / 0.35 ~ 2.857143 - r = fun.ra0 + s_ * (fun.ra1 + s_ * (fun.ra2 + s_ * (fun.ra3 + s_ * (fun.ra4 + - s_ * (fun.ra5 + s_ * (fun.ra6 + s_ * fun.ra7)))))) - s = 1.0 + s_ * (fun.sa1 + s_ * (fun.sa2 + s_ * (fun.sa3 + s_ * (fun.sa4 + - s_ * (fun.sa5 + s_ * (fun.sa6 + s_ * (fun.sa7 + s_ * fun.sa8))))))) + r = ra0 + s_ * (ra1 + s_ * (ra2 + s_ * (ra3 + s_ * (ra4 + s_ * (ra5 + s_ * (ra6 + + s_ * ra7)))))) + s = 1.0 + s_ * (sa1 + s_ * (sa2 + s_ * (sa3 + s_ * (sa4 + s_ * (sa5 + s_ * (sa6 + + s_ * (sa7 + s_ * sa8))))))) } else { // x| >= 1 / 0.35 ~ 2.857143 if sign && x > 6 { return f64(2) // x < -6 } - r = fun.rb0 + s_ * (fun.rb1 + s_ * (fun.rb2 + s_ * (fun.rb3 + s_ * (fun.rb4 + - s_ * (fun.rb5 + s_ * fun.rb6))))) - s = 1.0 + s_ * (fun.sb1 + s_ * (fun.sb2 + s_ * (fun.sb3 + s_ * (fun.sb4 + - s_ * (fun.sb5 + s_ * (fun.sb6 + s_ * fun.sb7)))))) + r = rb0 + s_ * (rb1 + s_ * (rb2 + s_ * (rb3 + s_ * (rb4 + s_ * (rb5 + s_ * rb6))))) + s = 1.0 + s_ * (sb1 + s_ * (sb2 + s_ * (sb3 + s_ * (sb4 + s_ * (sb5 + s_ * (sb6 + + s_ * sb7)))))) } z := math.f64_from_bits(math.f64_bits(x) & 0xffffffff00000000) // pseudo-single (20-bit) precision x r_ := math.exp(-z * z - 0.5625) * math.exp((z - x) * (z + x) + r / s) diff --git a/fun/trig.v b/fun/trig.v index defdb42f1..4b06edb2d 100644 --- a/fun/trig.v +++ b/fun/trig.v @@ -53,10 +53,10 @@ const sin_data = [ -1.1821555255364833468288e-19, ] const sin_cs = ChebSeries{ - c: sin_data + c: sin_data order: 11 - a: -1 - b: 1 + a: -1 + b: 1 } const cos_data = [ 0.165391825637921473505668118136, @@ -72,10 +72,10 @@ const cos_data = [ -3.7363121133079412079201377318e-18, ] const cos_cs = ChebSeries{ - c: cos_data + c: cos_data order: 10 - a: -1 - b: 1 + a: -1 + b: 1 } const p1 = 7.85398125648498535156e-1 const p2 = 3.77489470793079817668e-8 @@ -100,16 +100,16 @@ pub fn sin_e(x f64) (f64, f64) { octant -= 4 sgn_result = -sgn_result } - z := ((abs_x - y * fun.p1) - y * fun.p2) - y * fun.p3 + z := ((abs_x - y * p1) - y * p2) - y * p3 mut result := 0.0 mut result_err := 0.0 if octant == 0 { t := 8.0 * math.abs(z) / math.pi - 1.0 - sin_cs_val, _ := fun.sin_cs.eval_e(t) + sin_cs_val, _ := sin_cs.eval_e(t) result = z * (1.0 + z * z * sin_cs_val) } else { t := 8.0 * math.abs(z) / math.pi - 1.0 - cos_cs_val, _ := fun.cos_cs.eval_e(t) + cos_cs_val, _ := cos_cs.eval_e(t) result = 1.0 - 0.5 * z * z * (1.0 - z * z * cos_cs_val) } result *= sgn_result @@ -147,16 +147,16 @@ pub fn cos_e(x f64) (f64, f64) { if octant > 1 { sgn_result = -sgn_result } - z := ((abs_x - y * fun.p1) - y * fun.p2) - y * fun.p3 + z := ((abs_x - y * p1) - y * p2) - y * p3 mut result := 0.0 mut result_err := 0.0 if octant == 0 { t := 8.0 * math.abs(z) / math.pi - 1.0 - cos_cs_val, _ := fun.cos_cs.eval_e(t) + cos_cs_val, _ := cos_cs.eval_e(t) result = 1.0 - 0.5 * z * z * (1.0 - z * z * cos_cs_val) } else { t := 8.0 * math.abs(z) / math.pi - 1.0 - sin_cs_val, _ := fun.sin_cs.eval_e(t) + sin_cs_val, _ := sin_cs.eval_e(t) result = z * (1.0 + z * z * sin_cs_val) } result *= sgn_result @@ -192,15 +192,15 @@ pub fn sin(x f64) f64 { octant -= 4 sgn_result = -sgn_result } - z := ((abs_x - y * fun.p1) - y * fun.p2) - y * fun.p3 + z := ((abs_x - y * p1) - y * p2) - y * p3 mut result := 0.0 if octant == 0 { t := 8.0 * math.abs(z) / math.pi - 1.0 - sin_cs_val, _ := fun.sin_cs.eval_e(t) + sin_cs_val, _ := sin_cs.eval_e(t) result = z * (1.0 + z * z * sin_cs_val) } else { t := 8.0 * math.abs(z) / math.pi - 1.0 - cos_cs_val, _ := fun.cos_cs.eval_e(t) + cos_cs_val, _ := cos_cs.eval_e(t) result = 1.0 - 0.5 * z * z * (1.0 - z * z * cos_cs_val) } result *= sgn_result @@ -229,15 +229,15 @@ pub fn cos(x f64) f64 { if octant > 1 { sgn_result = -sgn_result } - z := ((abs_x - y * fun.p1) - y * fun.p2) - y * fun.p3 + z := ((abs_x - y * p1) - y * p2) - y * p3 mut result := 0.0 if octant == 0 { t := 8.0 * math.abs(z) / math.pi - 1.0 - cos_cs_val, _ := fun.cos_cs.eval_e(t) + cos_cs_val, _ := cos_cs.eval_e(t) result = 1.0 - 0.5 * z * z * (1.0 - z * z * cos_cs_val) } else { t := 8.0 * math.abs(z) / math.pi - 1.0 - sin_cs_val, _ := fun.sin_cs.eval_e(t) + sin_cs_val, _ := sin_cs.eval_e(t) result = z * (1.0 + z * z * sin_cs_val) } result *= sgn_result diff --git a/gm/bins.v b/gm/bins.v index 5cffe7cf3..ca9823db6 100644 --- a/gm/bins.v +++ b/gm/bins.v @@ -63,8 +63,8 @@ pub fn Bins.new(xmin []f64, xmax []f64, ndiv_ []int) &Bins { } o.xdel[k] = o.xmax[k] - o.xmin[k] o.size[k] = o.xdel[k] / f64(ndiv[k]) - if o.xdel[k] < gm.xdelzero { - errors.vsl_panic('xmax[${k}]-xmin[${k}]=${o.xdel[k]} must be greater than ${gm.xdelzero}', + if o.xdel[k] < xdelzero { + errors.vsl_panic('xmax[${k}]-xmin[${k}]=${o.xdel[k]} must be greater than ${xdelzero}', .efailed) } } diff --git a/graph/graph.v b/graph/graph.v index 4d0ad390c..84a25df68 100644 --- a/graph/graph.v +++ b/graph/graph.v @@ -45,14 +45,14 @@ pub fn Graph.new(edges [][]int, weights_e []f64, verts [][]f64, weights_v []f64) mut dist := [][]f64{len: nv, init: []f64{len: nv}} mut next := [][]int{len: nv, init: []int{len: nv}} return &Graph{ - edges: edges + edges: edges weights_e: weights_e - verts: verts + verts: verts weights_v: weights_v - shares: shares - key2edge: key2edge - dist: dist - next: next + shares: shares + key2edge: key2edge + dist: dist + next: next } } @@ -111,14 +111,14 @@ pub fn (g &Graph) shortest_paths(method ShortestPaths) Graph { } } return Graph{ - edges: g2.edges + edges: g2.edges weights_e: g2.weights_e - verts: g2.verts + verts: g2.verts weights_v: g2.weights_v - shares: g2.shares - key2edge: g2.key2edge - dist: dist - next: next + shares: g2.shares + key2edge: g2.key2edge + dist: dist + next: next } } @@ -182,14 +182,14 @@ pub fn (g &Graph) calc_dist() Graph { } } return Graph{ - edges: g.edges + edges: g.edges weights_e: g.weights_e - verts: g.verts + verts: g.verts weights_v: g.weights_v - shares: g.shares - key2edge: g.key2edge - dist: dist - next: next + shares: g.shares + key2edge: g.key2edge + dist: dist + next: next } } diff --git a/graph/graph_test.v b/graph/graph_test.v index d39188cab..2b3b7c7c1 100644 --- a/graph/graph_test.v +++ b/graph/graph_test.v @@ -42,14 +42,14 @@ fn test_graph01() { mut weights_e := g2.weights_e.clone() weights_e[3] = 13 g3 := &Graph{ - edges: g.edges + edges: g.edges weights_e: weights_e - verts: g.verts + verts: g.verts weights_v: g.weights_v - shares: g.shares - key2edge: g.key2edge - dist: g.dist - next: g.next + shares: g.shares + key2edge: g.key2edge + dist: g.dist + next: g.next } g4 := g3.shortest_paths(.fw) g4_path_0_3 := g4.path(0, 3) diff --git a/inout/h5/readhdf5_test.v b/inout/h5/readhdf5_test.v index 791bac4de..8074d65e3 100644 --- a/inout/h5/readhdf5_test.v +++ b/inout/h5/readhdf5_test.v @@ -9,23 +9,23 @@ const testfile = os.join_path(testfolder, h5data) const shortarray = []i32{len: 2} fn testsuite_begin() { - os.rmdir_all(h5.testfolder) or {} - os.mkdir_all(h5.testfolder)! + os.rmdir_all(testfolder) or {} + os.mkdir_all(testfolder)! - assert os.exists_in_system_path(h5.h5dump) + assert os.exists_in_system_path(h5dump) - f := Hdf5File.new(h5.testfile)! - f.write_dataset1d('Shortarray', h5.shortarray)! + f := Hdf5File.new(testfile)! + f.write_dataset1d('Shortarray', shortarray)! f.close() } fn testsuite_end() { - os.rmdir_all(h5.testfolder) or {} + os.rmdir_all(testfolder) or {} } // verify simple operation of one datatype (int) fn test_run() { - res := os.execute('h5dump ${h5.testfile}') + res := os.execute('h5dump ${testfile}') output := res.output.trim_space() assert output.contains('tsession') assert output.contains('Shortarray') diff --git a/inout/h5/three_d_test.v b/inout/h5/three_d_test.v index 89c4a0bc4..8e1eb21f2 100644 --- a/inout/h5/three_d_test.v +++ b/inout/h5/three_d_test.v @@ -43,7 +43,7 @@ fn test_3d() { } } - f := Hdf5File.new(h5.testfile)! + f := Hdf5File.new(testfile)! f.write_dataset3d('i8array', i8array)! f.write_dataset3d('u8array', u8array)! @@ -66,10 +66,10 @@ fn test_3d() { } fn testsuite_begin() { - os.rmdir_all(h5.testfolder) or {} - os.mkdir_all(h5.testfolder)! + os.rmdir_all(testfolder) or {} + os.mkdir_all(testfolder)! - assert os.exists_in_system_path(h5.h5dump) + assert os.exists_in_system_path(h5dump) test_3d() } @@ -80,7 +80,7 @@ fn testsuite_end() { // verify all datatypes in 3 dimensions fn test_run() { - res := os.execute('h5dump ${h5.testfile}') + res := os.execute('h5dump ${testfile}') output := res.output.trim_space() assert output.contains('i8array') assert output.contains('u8array') @@ -136,7 +136,7 @@ fn readback() ! { mut intarrayrd := make3type[int](1, 1, 1) - f := open_file(h5.testfile)! + f := open_file(testfile)! f.read_dataset3d('i8array', mut i8arrayrd) f.read_dataset3d('u8array', mut u8arrayrd) diff --git a/inout/h5/two_d_test.v b/inout/h5/two_d_test.v index 3d33f2e48..bdd6a136d 100644 --- a/inout/h5/two_d_test.v +++ b/inout/h5/two_d_test.v @@ -41,7 +41,7 @@ fn test_2d() { } } - f := Hdf5File.new(h5.testfile)! + f := Hdf5File.new(testfile)! f.write_dataset2d('i8array', i8array)! f.write_dataset2d('u8array', u8array)! @@ -64,21 +64,21 @@ fn test_2d() { } fn testsuite_begin() { - os.rmdir_all(h5.testfolder) or {} - os.mkdir_all(h5.testfolder)! + os.rmdir_all(testfolder) or {} + os.mkdir_all(testfolder)! - assert os.exists_in_system_path(h5.h5dump) + assert os.exists_in_system_path(h5dump) test_2d() } fn testsuite_end() { - os.rmdir_all(h5.testfolder) or {} + os.rmdir_all(testfolder) or {} } // verify all datatypes in 2 dimensions fn test_run() { - res := os.execute('h5dump ${h5.testfile}') + res := os.execute('h5dump ${testfile}') output := res.output.trim_space() assert output.contains('i8array') assert output.contains('u8array') @@ -134,7 +134,7 @@ fn readback() ! { mut intarrayrd := make2type[int](1, 1) - f := open_file(h5.testfile)! + f := open_file(testfile)! f.read_dataset2d('i8array', mut i8arrayrd) f.read_dataset2d('u8array', mut u8arrayrd) diff --git a/inout/h5/typeshdf5_test.v b/inout/h5/typeshdf5_test.v index 60e41955e..f78b574e3 100644 --- a/inout/h5/typeshdf5_test.v +++ b/inout/h5/typeshdf5_test.v @@ -25,29 +25,29 @@ const f64array = make1type[f64](2) const intarray = make1type[int](2) fn testsuite_begin() { - os.rmdir_all(h5.testfolder) or {} - os.mkdir_all(h5.testfolder)! + os.rmdir_all(testfolder) or {} + os.mkdir_all(testfolder)! - assert os.exists_in_system_path(h5.h5dump) + assert os.exists_in_system_path(h5dump) - f := Hdf5File.new(h5.testfile)! + f := Hdf5File.new(testfile)! - f.write_dataset1d('i8array', h5.i8array)! - f.write_dataset1d('u8array', h5.u8array)! + f.write_dataset1d('i8array', i8array)! + f.write_dataset1d('u8array', u8array)! - f.write_dataset1d('i16array', h5.i16array)! - f.write_dataset1d('u16array', h5.u16array)! + f.write_dataset1d('i16array', i16array)! + f.write_dataset1d('u16array', u16array)! - f.write_dataset1d('i32array', h5.i32array)! - f.write_dataset1d('u32array', h5.u32array)! + f.write_dataset1d('i32array', i32array)! + f.write_dataset1d('u32array', u32array)! - f.write_dataset1d('i64array', h5.i64array)! - f.write_dataset1d('u64array', h5.u64array)! + f.write_dataset1d('i64array', i64array)! + f.write_dataset1d('u64array', u64array)! - f.write_dataset1d('intarray', h5.intarray)! + f.write_dataset1d('intarray', intarray)! - f.write_dataset1d('f32array', h5.f32array)! - f.write_dataset1d('f64array', h5.f64array)! + f.write_dataset1d('f32array', f32array)! + f.write_dataset1d('f64array', f64array)! f.close() } @@ -58,7 +58,7 @@ fn testsuite_end() { // verify all datatypes in 1 dimension fn test_run() { - res := os.execute('h5dump ${h5.testfile}') + res := os.execute('h5dump ${testfile}') output := res.output.trim_space() assert output.contains('i8array') assert output.contains('u8array') @@ -117,35 +117,35 @@ fn readback() ! { mut intarrayrd := make1type[int](1) - f := open_file(h5.testfile)! + f := open_file(testfile)! f.read_dataset1d('i8array', mut i8arrayrd) f.read_dataset1d('u8array', mut u8arrayrd) - compare1d(h5.i8array, i8arrayrd) - compare1d(h5.u8array, u8arrayrd) + compare1d(i8array, i8arrayrd) + compare1d(u8array, u8arrayrd) f.read_dataset1d('i16array', mut i16arrayrd) f.read_dataset1d('u16array', mut u16arrayrd) - compare1d(h5.i16array, i16arrayrd) - compare1d(h5.u16array, u16arrayrd) + compare1d(i16array, i16arrayrd) + compare1d(u16array, u16arrayrd) f.read_dataset1d('i32array', mut i32arrayrd) f.read_dataset1d('u32array', mut u32arrayrd) - compare1d(h5.i32array, i32arrayrd) - compare1d(h5.u32array, u32arrayrd) + compare1d(i32array, i32arrayrd) + compare1d(u32array, u32arrayrd) f.read_dataset1d('i64array', mut i64arrayrd) f.read_dataset1d('u64array', mut u64arrayrd) - compare1d(h5.i64array, i64arrayrd) - compare1d(h5.u64array, u64arrayrd) + compare1d(i64array, i64arrayrd) + compare1d(u64array, u64arrayrd) f.read_dataset1d('f32array', mut f32arrayrd) f.read_dataset1d('f64array', mut f64arrayrd) - compare1d(h5.f32array, f32arrayrd) - compare1d(h5.f64array, f64arrayrd) + compare1d(f32array, f32arrayrd) + compare1d(f64array, f64arrayrd) f.read_dataset1d('intarray', mut intarrayrd) - compare1d(h5.intarray, intarrayrd) + compare1d(intarray, intarrayrd) f.close() } diff --git a/iter/comb.v b/iter/comb.v index e5fe09d1a..7320feedc 100644 --- a/iter/comb.v +++ b/iter/comb.v @@ -31,17 +31,17 @@ pub fn CombinationsIter.new(data []f64, r int) CombinationsIter { n := data.len if r > n { return CombinationsIter{ - data: data + data: data repeat: r } } size := u64(fun.choose(n, r)) idxs := util.arange(r) return CombinationsIter{ - data: data + data: data repeat: r - size: size - idxs: idxs + size: size + idxs: idxs } } @@ -108,17 +108,17 @@ pub fn CombinationsWithReplacementIter.new(data []f64, r int) CombinationsWithRe n := data.len if r > n { return CombinationsWithReplacementIter{ - data: data + data: data repeat: r } } size := fun.n_combos_w_replacement(n, r) idxs := []int{len: r, init: 0} return CombinationsWithReplacementIter{ - data: data + data: data repeat: r - size: size - idxs: idxs + size: size + idxs: idxs } } diff --git a/iter/inf_iters.v b/iter/inf_iters.v index 883f8ee0b..b827b355c 100644 --- a/iter/inf_iters.v +++ b/iter/inf_iters.v @@ -9,7 +9,7 @@ pub mut: pub fn Counter.new(start f64, step f64) Counter { return Counter{ - step: step + step: step state: start } } @@ -30,7 +30,7 @@ pub: pub fn Cycler.new(data []f64) Cycler { return Cycler{ data: data - idx: 0 + idx: 0 } } diff --git a/iter/perm.v b/iter/perm.v index 369c87bdc..a18d5f5ba 100644 --- a/iter/perm.v +++ b/iter/perm.v @@ -20,7 +20,7 @@ pub fn PermutationsIter.new(data []f64, r int) PermutationsIter { n := data.len if r > n { return PermutationsIter{ - data: data + data: data repeat: r } } @@ -28,10 +28,10 @@ pub fn PermutationsIter.new(data []f64, r int) PermutationsIter { idxs := util.arange(n) cycles := util.range(n, n - r, step: -1) return PermutationsIter{ - data: data + data: data repeat: r - size: size - idxs: idxs + size: size + idxs: idxs cycles: cycles } } diff --git a/iter/prod.v b/iter/prod.v index 4b7cf281a..c8f8989e0 100644 --- a/iter/prod.v +++ b/iter/prod.v @@ -14,10 +14,10 @@ pub: pub fn ProductIterator.new(data [][]f64) ProductIterator { return ProductIterator{ - repeat_lengths: calc_repeat_lengths(data.map(it.len)).map(u64(it)) + repeat_lengths: calc_repeat_lengths(data.map(it.len)).map(u64(it)) indices_to_grab: []int{len: data.len, init: -1} - data: data - size: u64(arrays.fold(data.map(it.len), 1, int_prod)) + data: data + size: u64(arrays.fold(data.map(it.len), 1, int_prod)) } } diff --git a/iter/ranges.v b/iter/ranges.v index 27e48b6b6..818ccc88b 100644 --- a/iter/ranges.v +++ b/iter/ranges.v @@ -42,10 +42,10 @@ pub fn IntIter.new(params IntIterParams) !IntIter { return IntIter{ start: params.start - stop: params.stop - step: params.step - i: 0 - len: len + stop: params.stop + step: params.step + i: 0 + len: len } } @@ -97,10 +97,10 @@ pub fn FloatIter.new(params FloatIterParams) !FloatIter { } return FloatIter{ start: params.start - stop: params.stop - step: params.step - i: 0 - len: len + stop: params.stop + step: params.step + i: 0 + len: len } } @@ -157,10 +157,10 @@ pub fn LinearIter.new(params LinearIterParams) !LinearIter { step = (params.stop - params.start) / params.len } return LinearIter{ - start: params.start - stop: params.stop - step: step - len: params.len + start: params.start + stop: params.stop + step: step + len: params.len endpoint: params.endpoint } } @@ -218,13 +218,13 @@ pub fn LogIter.new(params LogIterParams) !LogIter { } return LogIter{ linear_iter: LinearIter.new( - start: params.start - stop: params.stop - len: params.len + start: params.start + stop: params.stop + len: params.len endpoint: params.endpoint )! base: params.base - len: params.len + len: params.len } } diff --git a/la/densesol_test.v b/la/densesol_test.v index febb18b54..2981e4c3c 100644 --- a/la/densesol_test.v +++ b/la/densesol_test.v @@ -13,7 +13,7 @@ fn test_den_solve() { b1 := [1.0, 1] mut x1 := []f64{len: mat1.m} den_solve(mut x1, mat1, b1, false) - assert float64.arrays_tolerance(x1, [1.0, 0.5], la.debsesol_tests_tol) + assert float64.arrays_tolerance(x1, [1.0, 0.5], debsesol_tests_tol) // case 2 mat2 := Matrix.deep2([ [2.0, 0, 0, -5.6], @@ -29,5 +29,5 @@ fn test_den_solve() { 0.32846811308349777, -0.20118343195266275, 0.8454963839579225, - ], la.debsesol_tests_tol) + ], debsesol_tests_tol) } diff --git a/la/matrix.v b/la/matrix.v index 88f2f2f41..80b5b8510 100644 --- a/la/matrix.v +++ b/la/matrix.v @@ -16,8 +16,8 @@ pub mut: pub fn Matrix.new[T](m int, n int) &Matrix[T] { data := []T{len: m * n} return &Matrix[T]{ - m: m - n: n + m: m + n: n data: data } } @@ -38,8 +38,8 @@ pub fn Matrix.deep2[T](a [][]T) &Matrix[T] { // (2) the external slice rawdata should not be changed or deleted pub fn Matrix.raw[T](m int, n int, rawdata []T) &Matrix[T] { return &Matrix[T]{ - m: m - n: n + m: m + n: n data: rawdata } } diff --git a/la/matrix_ops.v b/la/matrix_ops.v index a541ed011..66e1f1a6d 100644 --- a/la/matrix_ops.v +++ b/la/matrix_ops.v @@ -90,7 +90,7 @@ pub fn matrix_svd(mut s []f64, mut u Matrix[f64], mut vt Matrix[f64], mut a Matr if copy_a { acpy = a.clone() } - vlas.dgesvd(`A`, `A`, a.m, a.n, acpy.data, 1, s, u.data, a.m, vt.data, a.n, superb) + vlas.dgesvd(c'A', c'A', a.m, a.n, acpy.data, 1, s, u.data, a.m, vt.data, a.n, superb) } // matrix_inv computes the inverse of a general matrix (square or not). It also computes the diff --git a/la/matrix_ops_test.v b/la/matrix_ops_test.v index 3e552994c..ada8bc4b3 100644 --- a/la/matrix_ops_test.v +++ b/la/matrix_ops_test.v @@ -9,7 +9,7 @@ fn tolerance_equal[T](data1 []T, data2 []T) bool { return false } for i := 0; i < data1.len; i++ { - if f64(math.abs(data1[i] - data2[i])) > la.matrix_tests_tol { + if f64(math.abs(data1[i] - data2[i])) > matrix_tests_tol { return false } } @@ -28,7 +28,7 @@ fn test_det() { [2.0, 8.0, 7.0], ]) $if macos { - assert math.tolerance(matrix_det(mat_b), -306, la.matrix_tests_tol) + assert math.tolerance(matrix_det(mat_b), -306, matrix_tests_tol) } $else { assert matrix_det(mat_b) == -306 } @@ -41,9 +41,9 @@ fn test_matrix_inv_small() { [0.0, 1.0], ]) mut inv1 := Matrix.new[f64](2, 2) - det1 := matrix_inv_small(mut inv1, mat1, la.matrix_tests_tol) + det1 := matrix_inv_small(mut inv1, mat1, matrix_tests_tol) assert tolerance_equal(mat1.data, inv1.data) - assert math.abs(det1 - 1.0) <= la.matrix_tests_tol + assert math.abs(det1 - 1.0) <= matrix_tests_tol // case 2 mat2 := Matrix.deep2([ [2.0, 3.0], @@ -54,9 +54,9 @@ fn test_matrix_inv_small() { [3.0, -2.0], ]) mut inv2 := Matrix.new[f64](2, 2) - det2 := matrix_inv_small(mut inv2, mat2, la.matrix_tests_tol) + det2 := matrix_inv_small(mut inv2, mat2, matrix_tests_tol) assert tolerance_equal(inv2.data, ex2.data) - assert math.abs(det2 + 1.0) <= la.matrix_tests_tol + assert math.abs(det2 + 1.0) <= matrix_tests_tol // case 3 mat3 := Matrix.deep2([ [-2.0, 2.0, 0.0], @@ -69,14 +69,14 @@ fn test_matrix_inv_small() { [5.0 / 12, 1.0 / 6, -1.0 / 4], ]) mut inv3 := Matrix.new[f64](3, 3) - det3 := matrix_inv_small(mut inv3, mat3, la.matrix_tests_tol) + det3 := matrix_inv_small(mut inv3, mat3, matrix_tests_tol) assert tolerance_equal(inv3.data, ex3.data) - assert math.abs(det3 - 24.0) <= la.matrix_tests_tol + assert math.abs(det3 - 24.0) <= matrix_tests_tol // case 4 mat4 := Matrix.deep2([[14.0]]) ex4 := Matrix.deep2([[1.0 / 14]]) mut inv4 := Matrix.new[f64](1, 1) - det4 := matrix_inv_small(mut inv4, mat4, la.matrix_tests_tol) + det4 := matrix_inv_small(mut inv4, mat4, matrix_tests_tol) assert tolerance_equal(inv4.data, ex4.data) - assert math.abs(det4 - 14.0) <= la.matrix_tests_tol + assert math.abs(det4 - 14.0) <= matrix_tests_tol } diff --git a/la/sparse_config.v b/la/sparse_config.v index 9c2271d0a..95e5bd4ec 100644 --- a/la/sparse_config.v +++ b/la/sparse_config.v @@ -23,7 +23,7 @@ pub mut: pub fn SparseConfig.new() SparseConfig { mut o := SparseConfig{ mumps_increase_of_working_space_pct: 100 - mumps_max_memory_per_processor: 2000 + mumps_max_memory_per_processor: 2000 } o.set_mumps_ordering('') o.set_mumps_scaling('') @@ -34,8 +34,8 @@ pub fn SparseConfig.new() SparseConfig { pub fn SparseConfig.with_comm(comm &mpi.Communicator) SparseConfig { mut o := SparseConfig{ mumps_increase_of_working_space_pct: 100 - mumps_max_memory_per_processor: 2000 - communicator: unsafe { comm } + mumps_max_memory_per_processor: 2000 + communicator: unsafe { comm } } o.set_mumps_ordering('') o.set_mumps_scaling('') diff --git a/ml/data.v b/ml/data.v index 1a186bca2..8d4c1ba97 100644 --- a/ml/data.v +++ b/ml/data.v @@ -49,9 +49,9 @@ pub fn Data.new[T](nb_samples int, nb_features int, use_y bool, allocate bool) ! y = []T{len: nb_samples} } return &Data[T]{ - x: x - y: y - nb_samples: nb_samples + x: x + y: y + nb_samples: nb_samples nb_features: nb_features } } @@ -175,9 +175,9 @@ pub fn (o &Data[T]) clone() !&Data[T] { pub fn (o &Data[T]) clone_with_same_x() !&Data[T] { use_y := o.y.len > 0 return &Data[T]{ - x: o.x - y: if use_y { o.y.clone() } else { []T{} } - nb_samples: o.nb_samples + x: o.x + y: if use_y { o.y.clone() } else { []T{} } + nb_samples: o.nb_samples nb_features: o.nb_features } } diff --git a/ml/kmeans.v b/ml/kmeans.v index 87c39f583..527f9c2d5 100644 --- a/ml/kmeans.v +++ b/ml/kmeans.v @@ -36,14 +36,14 @@ pub fn Kmeans.new(mut data Data[f64], nb_classes int, name string) &Kmeans { ndiv := [10, 10] // TODO: make this a parameter mut bins := gm.Bins.new(stat.min_x, stat.max_x, ndiv) // TODO: make sure minx and maxx are 2D or 3D; i.e. nb_features ≤ 2 mut o := Kmeans{ - name: name - data: data - stat: stat + name: name + data: data + stat: stat nb_classes: nb_classes - classes: classes - centroids: centroids + classes: classes + centroids: centroids nb_members: nb_members - bins: bins + bins: bins } data.add_observer(o) // need to recompute bins upon data changes o.update() // compute first bins @@ -172,12 +172,12 @@ pub fn (o &Kmeans) get_plotter() &plot.Plot { } plt.scatter( - name: 'class #${i}' - x: x_for_class - y: y_for_class - mode: 'markers' + name: 'class #${i}' + x: x_for_class + y: y_for_class + mode: 'markers' colorscale: 'smoker' - marker: plot.Marker{ + marker: plot.Marker{ size: []f64{len: x_for_class.len, init: 8.0} // Adjust size as needed } ) @@ -185,12 +185,12 @@ pub fn (o &Kmeans) get_plotter() &plot.Plot { // Plot centroids plt.scatter( - name: 'centroids' - x: o.centroids.map(it[0]) - y: o.centroids.map(it[1]) - mode: 'markers' + name: 'centroids' + x: o.centroids.map(it[0]) + y: o.centroids.map(it[1]) + mode: 'markers' colorscale: 'smoker' - marker: plot.Marker{ + marker: plot.Marker{ size: []f64{len: o.centroids.len, init: 12.0} // Adjust size as needed } ) diff --git a/ml/knn.v b/ml/knn.v index c84db9397..c6272b2bd 100644 --- a/ml/knn.v +++ b/ml/knn.v @@ -227,12 +227,12 @@ pub fn (o &KNN) get_plotter() &plot.Plot { } plt.scatter( - name: 'class #${i}' - x: x_for_class - y: y_for_class - mode: 'markers' + name: 'class #${i}' + x: x_for_class + y: y_for_class + mode: 'markers' colorscale: 'smoker' - marker: plot.Marker{ + marker: plot.Marker{ size: []f64{len: x_for_class.len, init: 8.0} // Adjust size as needed } ) diff --git a/ml/linreg.v b/ml/linreg.v index 20b1cf98a..770025b51 100644 --- a/ml/linreg.v +++ b/ml/linreg.v @@ -27,10 +27,10 @@ pub fn LinReg.new(mut data Data[f64], name string) &LinReg { stat.update() params := ParamsReg.new[f64](data.nb_features) mut reg := &LinReg{ - name: name - data: data - stat: stat - e: []f64{len: data.nb_samples} + name: name + data: data + stat: stat + e: []f64{len: data.nb_samples} params: params } return reg @@ -169,14 +169,14 @@ pub fn (o &LinReg) get_plotter() &plot.Plot { ) plt.scatter( name: 'dataset' - x: o.data.x.get_col(0) - y: o.data.y + x: o.data.x.get_col(0) + y: o.data.y mode: 'markers' ) plt.scatter( name: 'prediction' - x: x_values - y: y_values + x: x_values + y: y_values mode: 'lines' ) diff --git a/ml/nlp/tokenizer.v b/ml/nlp/tokenizer.v index d39c567db..628f956c0 100644 --- a/ml/nlp/tokenizer.v +++ b/ml/nlp/tokenizer.v @@ -10,7 +10,7 @@ pub const ngram_sep = 'NGRAMSEP' // `,.[]()[]-=_*;:+><\\"`´~^!?@#$%¨&/|'` pub fn remove_punctuation(x string) string { mut new_x := x - for punct in (nlp.punctuation.join('') + "'").split('') { + for punct in (punctuation.join('') + "'").split('') { new_x = new_x.replace(punct, '') } return new_x @@ -42,7 +42,7 @@ pub fn tokenize(x string) []string { continue } - if current_char in nlp.punctuation { + if current_char in punctuation { tokens << current_piece tokens << current_char current_piece = '' diff --git a/ml/paramsreg.v b/ml/paramsreg.v index 2608f1138..16804d110 100644 --- a/ml/paramsreg.v +++ b/ml/paramsreg.v @@ -24,7 +24,7 @@ pub fn ParamsReg.new[T](nb_features int) &ParamsReg[T] { theta := []T{len: nb_features} bkp_theta := []T{len: nb_features} return &ParamsReg[T]{ - theta: theta + theta: theta bkp_theta: bkp_theta } } diff --git a/ml/workspace.v b/ml/workspace.v index 110d03640..ffb74b40f 100644 --- a/ml/workspace.v +++ b/ml/workspace.v @@ -30,14 +30,14 @@ pub mut: // stat returns a new Stat object pub fn Stat.from_data[T](mut data Data[T], name string) &Stat[T] { mut o := &Stat[T]{ - name: name - data: data - min_x: []T{len: data.nb_features} - max_x: []T{len: data.nb_features} - sum_x: []T{len: data.nb_features} + name: name + data: data + min_x: []T{len: data.nb_features} + max_x: []T{len: data.nb_features} + sum_x: []T{len: data.nb_features} mean_x: []T{len: data.nb_features} - sig_x: []T{len: data.nb_features} - del_x: []T{len: data.nb_features} + sig_x: []T{len: data.nb_features} + del_x: []T{len: data.nb_features} } data.add_observer(o) return o diff --git a/mpi/mpi.c.v b/mpi/mpi.c.v index b6074401c..a20c89692 100644 --- a/mpi/mpi.c.v +++ b/mpi/mpi.c.v @@ -87,7 +87,7 @@ mut: // Note there is currently no means to use groups. pub fn Communicator.new(ranks []int) !&Communicator { mut o := &Communicator{ - comm: MPI_Comm(C.MPI_COMM_WORLD) + comm: MPI_Comm(C.MPI_COMM_WORLD) group: unsafe { nil } } if ranks.len == 0 { diff --git a/noise/simplex.v b/noise/simplex.v index 176fe40a6..202fe7b2b 100644 --- a/noise/simplex.v +++ b/noise/simplex.v @@ -110,11 +110,11 @@ pub fn (generator Generator) simplex_1d(x f64) f64 { // simplex_2d returns a simplex noise value for a given x, y position pub fn (generator Generator) simplex_2d(x f64, y f64) f64 { - s := (x + y) * noise.f2 + s := (x + y) * f2 i := int(x + s) j := int(y + s) - t := f64(i + j) * noise.g2 + t := f64(i + j) * g2 x0 := x - (i - t) y0 := y - (j - t) @@ -124,10 +124,10 @@ pub fn (generator Generator) simplex_2d(x f64, y f64) f64 { 0, 1 } - x1 := x0 - f64(i1) + noise.g2 - y1 := y0 - f64(j1) + noise.g2 - x2 := x0 - 1.0 + noise.g2 * 2.0 - y2 := y0 - 1.0 + noise.g2 * 2.0 + x1 := x0 - f64(i1) + g2 + y1 := y0 - f64(j1) + g2 + x2 := x0 - 1.0 + g2 * 2.0 + y2 := y0 - 1.0 + g2 * 2.0 ii := i & 0xff jj := j & 0xff @@ -165,7 +165,7 @@ pub fn (generator Generator) simplex_2d(x f64, y f64) f64 { // simplex_3d returns a simplex noise value for a given x, y, z position pub fn (generator Generator) simplex_3d(x f64, y f64, z f64) f64 { - s := (x + y + z) * noise.f3 + s := (x + y + z) * f3 xs := x + s ys := y + s zs := z + s @@ -173,7 +173,7 @@ pub fn (generator Generator) simplex_3d(x f64, y f64, z f64) f64 { j := int(ys) k := int(zs) - t := f64(i + j + k) * noise.g3 + t := f64(i + j + k) * g3 x0 := x - (i - t) y0 := y - (j - t) z0 := z - (k - t) @@ -215,15 +215,15 @@ pub fn (generator Generator) simplex_3d(x f64, y f64, z f64) f64 { } } - x1 := x0 - i1 + noise.g3 - y1 := y0 - j1 + noise.g3 - z1 := z0 - k1 + noise.g3 - x2 := x0 - i2 + 2.0 * noise.g3 - y2 := y0 - j2 + 2.0 * noise.g3 - z2 := z0 - k2 + 2.0 * noise.g3 - x3 := x0 - 1.0 + 3.0 * noise.g3 - y3 := y0 - 1.0 + 3.0 * noise.g3 - z3 := z0 - 1.0 + 3.0 * noise.g3 + x1 := x0 - i1 + g3 + y1 := y0 - j1 + g3 + z1 := z0 - k1 + g3 + x2 := x0 - i2 + 2.0 * g3 + y2 := y0 - j2 + 2.0 * g3 + z2 := z0 - k2 + 2.0 * g3 + x3 := x0 - 1.0 + 3.0 * g3 + y3 := y0 - 1.0 + 3.0 * g3 + z3 := z0 - 1.0 + 3.0 * g3 ii := i & 0xff jj := j & 0xff @@ -274,7 +274,7 @@ pub fn (generator Generator) simplex_3d(x f64, y f64, z f64) f64 { // simplex_4d returns a simplex noise value for a given x, y, z, w position pub fn (generator Generator) simplex_4d(x f64, y f64, z f64, w f64) f64 { - s := (x + y + z + w) * noise.f4 + s := (x + y + z + w) * f4 xs := x + s ys := y + s zs := z + s @@ -284,7 +284,7 @@ pub fn (generator Generator) simplex_4d(x f64, y f64, z f64, w f64) f64 { k := int(zs) l := int(ws) - t := f64(i + j + k + l) * noise.g4 + t := f64(i + j + k + l) * g4 x0 := x - (i - t) y0 := y - (j - t) z0 := z - (k - t) @@ -298,37 +298,37 @@ pub fn (generator Generator) simplex_4d(x f64, y f64, z f64, w f64) f64 { c6 := if z0 > w0 { 1 } else { 0 } c := c1 + c2 + c3 + c4 + c5 + c6 - i1 := if noise.simplex[c][0] >= 3 { 1 } else { 0 } - j1 := if noise.simplex[c][1] >= 3 { 1 } else { 0 } - k1 := if noise.simplex[c][2] >= 3 { 1 } else { 0 } - l1 := if noise.simplex[c][3] >= 3 { 1 } else { 0 } - - i2 := if noise.simplex[c][0] >= 2 { 1 } else { 0 } - j2 := if noise.simplex[c][1] >= 2 { 1 } else { 0 } - k2 := if noise.simplex[c][2] >= 2 { 1 } else { 0 } - l2 := if noise.simplex[c][3] >= 2 { 1 } else { 0 } - - i3 := if noise.simplex[c][0] >= 1 { 1 } else { 0 } - j3 := if noise.simplex[c][1] >= 1 { 1 } else { 0 } - k3 := if noise.simplex[c][2] >= 1 { 1 } else { 0 } - l3 := if noise.simplex[c][3] >= 1 { 1 } else { 0 } - - x1 := x0 - i1 + noise.g4 - y1 := y0 - j1 + noise.g4 - z1 := z0 - k1 + noise.g4 - w1 := w0 - l1 + noise.g4 - x2 := x0 - i2 + 2.0 * noise.g4 - y2 := y0 - j2 + 2.0 * noise.g4 - z2 := z0 - k2 + 2.0 * noise.g4 - w2 := w0 - l2 + 2.0 * noise.g4 - x3 := x0 - i3 + 3.0 * noise.g4 - y3 := y0 - j3 + 3.0 * noise.g4 - z3 := z0 - k3 + 3.0 * noise.g4 - w3 := w0 - l3 + 3.0 * noise.g4 - x4 := x0 - 1.0 + 4.0 * noise.g4 - y4 := y0 - 1.0 + 4.0 * noise.g4 - z4 := z0 - 1.0 + 4.0 * noise.g4 - w4 := w0 - 1.0 + 4.0 * noise.g4 + i1 := if simplex[c][0] >= 3 { 1 } else { 0 } + j1 := if simplex[c][1] >= 3 { 1 } else { 0 } + k1 := if simplex[c][2] >= 3 { 1 } else { 0 } + l1 := if simplex[c][3] >= 3 { 1 } else { 0 } + + i2 := if simplex[c][0] >= 2 { 1 } else { 0 } + j2 := if simplex[c][1] >= 2 { 1 } else { 0 } + k2 := if simplex[c][2] >= 2 { 1 } else { 0 } + l2 := if simplex[c][3] >= 2 { 1 } else { 0 } + + i3 := if simplex[c][0] >= 1 { 1 } else { 0 } + j3 := if simplex[c][1] >= 1 { 1 } else { 0 } + k3 := if simplex[c][2] >= 1 { 1 } else { 0 } + l3 := if simplex[c][3] >= 1 { 1 } else { 0 } + + x1 := x0 - i1 + g4 + y1 := y0 - j1 + g4 + z1 := z0 - k1 + g4 + w1 := w0 - l1 + g4 + x2 := x0 - i2 + 2.0 * g4 + y2 := y0 - j2 + 2.0 * g4 + z2 := z0 - k2 + 2.0 * g4 + w2 := w0 - l2 + 2.0 * g4 + x3 := x0 - i3 + 3.0 * g4 + y3 := y0 - j3 + 3.0 * g4 + z3 := z0 - k3 + 3.0 * g4 + w3 := w0 - l3 + 3.0 * g4 + x4 := x0 - 1.0 + 4.0 * g4 + y4 := y0 - 1.0 + 4.0 * g4 + z4 := z0 - 1.0 + 4.0 * g4 + w4 := w0 - 1.0 + 4.0 * g4 ii := i & 0xff jj := j & 0xff diff --git a/plot/show.v b/plot/show.v index fd676540a..6bd596180 100644 --- a/plot/show.v +++ b/plot/show.v @@ -25,16 +25,16 @@ pub fn (p Plot) show(config PlotConfig) ! { } $else { mut handler := PlotlyHandler{ use_cdn: true - plot: p + plot: p } listener := net.listen_tcp(net.AddrFamily.ip, config.saddr, dualstack: config.dualstack - backlog: config.backlog + backlog: config.backlog )! mut server := &http.Server{ accept_timeout: config.timeout - listener: listener - handler: handler + listener: listener + handler: handler } handler.server = server t := spawn server.listen_and_serve() @@ -63,7 +63,7 @@ pub fn (p Plot) get_plotly_script(element_id string, config PlotlyScriptConfig) layout_json := encode(p.layout) plot_script := &html.Tag{ - name: 'script' + name: 'script' attributes: { 'type': 'module' } @@ -126,7 +126,7 @@ mut: fn (mut handler PlotlyHandler) handle(req http.Request) http.Response { mut r := http.Response{ - body: handler.plot.get_html('gd', use_cdn: handler.use_cdn) + body: handler.plot.get_html('gd', use_cdn: handler.use_cdn) header: req.header } r.set_status(.ok) diff --git a/poly/poly.v b/poly/poly.v index acf36c397..7b775f754 100644 --- a/poly/poly.v +++ b/poly/poly.v @@ -213,17 +213,17 @@ pub fn balance_companion_matrix(cm [][]f64) [][]f64 { if col_norm == 0.0 || row_norm == 0.0 { continue } - mut g := row_norm / poly.radix + mut g := row_norm / radix mut f := 1.0 s := col_norm + row_norm for col_norm < g { - f *= poly.radix - col_norm *= poly.radix2 + f *= radix + col_norm *= radix2 } - g = row_norm * poly.radix + g = row_norm * radix for col_norm > g { - f /= poly.radix - col_norm /= poly.radix2 + f /= radix + col_norm /= radix2 } if (row_norm + col_norm) < 0.95 * s * f { not_converged = true diff --git a/roots/bisection.v b/roots/bisection.v index d2ed220fe..b1bf95564 100644 --- a/roots/bisection.v +++ b/roots/bisection.v @@ -32,12 +32,12 @@ pub: // Bisection.new creates a new Bisection object with the given parameters pub fn Bisection.new(f func.Fn, params BisectionParams) &Bisection { return &Bisection{ - f: f - xmin: params.xmin - xmax: params.xmax + f: f + xmin: params.xmin + xmax: params.xmax epsrel: params.epsrel epsabs: params.epsabs - n_max: params.n_max + n_max: params.n_max } } @@ -60,10 +60,10 @@ pub fn (mut solver Bisection) next() ?&BisectionIteration { solver.n_f_calls += 1 if math.abs(fxmid) < solver.epsabs || math.abs(fxmid) < solver.epsrel * math.abs(fxmid) { solver.last_iter = &BisectionIteration{ - x: xmid - fx: fxmid + x: xmid + fx: fxmid n_f_calls: solver.n_f_calls - n_iter: solver.n_iter + n_iter: solver.n_iter } return solver.last_iter? } @@ -75,10 +75,10 @@ pub fn (mut solver Bisection) next() ?&BisectionIteration { } solver.last_iter = &BisectionIteration{ - x: xmid - fx: fxmid + x: xmid + fx: fxmid n_f_calls: solver.n_f_calls - n_iter: solver.n_iter + n_iter: solver.n_iter } return solver.last_iter? } diff --git a/roots/brent.v b/roots/brent.v index 8b2b9e459..cb64b637b 100644 --- a/roots/brent.v +++ b/roots/brent.v @@ -25,7 +25,7 @@ pub mut: // Brent.new creates a new Brent object pub fn Brent.new(f func.Fn) &Brent { return &Brent{ - f: f + f: f tol: 1e-6 } } @@ -62,7 +62,7 @@ fn brent(f func.Fn, x1 f64, x2 f64, tol f64) !(f64, f64) { mut p := 0.0 mut q := 0.0 mut r := 0.0 - for iter := 1; iter <= roots.itmax; iter++ { + for iter := 1; iter <= itmax; iter++ { prev_step = b - a if math.abs(fc) < math.abs(fb) { a = b diff --git a/roots/roots_test.v b/roots/roots_test.v index 8c8a61210..6aa6d7a96 100644 --- a/roots/roots_test.v +++ b/roots/roots_test.v @@ -19,19 +19,19 @@ fn fdf_cos(x f64, _ []f64) (f64, f64) { fn test_root_bisection() { f := func.Fn.new(f: f_cos) mut solver := Bisection.new(f, - xmin: 0.0 - xmax: 3.0 - epsrel: roots.epsrel - epsabs: roots.epsabs - n_max: roots.n_max + xmin: 0.0 + xmax: 3.0 + epsrel: epsrel + epsabs: epsabs + n_max: n_max ) result := solver.solve()? - assert float64.soclose(result.x, math.pi / 2.00, roots.epsabs) + assert float64.soclose(result.x, math.pi / 2.00, epsabs) } fn test_root_newton() { x0 := f64(0.5) f := func.FnFdf.new(fdf: fdf_cos) - result := newton(f, x0, roots.epsrel, roots.epsabs, roots.n_max)! - assert float64.soclose(result, math.pi / 2.00, roots.epsabs) + result := newton(f, x0, epsrel, epsabs, n_max)! + assert float64.soclose(result, math.pi / 2.00, epsabs) } diff --git a/vcl/buffer.c.v b/vcl/buffer.c.v index b096d60c0..f4d1b69af 100644 --- a/vcl/buffer.c.v +++ b/vcl/buffer.c.v @@ -19,7 +19,7 @@ fn (d &Device) buffer(size int) !&Buffer { return err_unknown } return &Buffer{ - size: size + size: size device: d memobj: buffer } diff --git a/vcl/device.c.v b/vcl/device.c.v index 810a549c1..619927c35 100644 --- a/vcl/device.c.v +++ b/vcl/device.c.v @@ -87,37 +87,37 @@ pub fn (d &Device) str() string { // name device info - name pub fn (d &Device) name() !string { - return d.get_info_str(vcl.device_name, true) + return d.get_info_str(device_name, true) } // vendor device info - vendor pub fn (d &Device) vendor() !string { - return d.get_info_str(vcl.device_vendor, true) + return d.get_info_str(device_vendor, true) } // extensions device info - extensions pub fn (d &Device) extensions() !string { - return d.get_info_str(vcl.device_extensions, true) + return d.get_info_str(device_extensions, true) } // open_clc_version device info - OpenCL C version pub fn (d &Device) open_clc_version() !string { - return d.get_info_str(vcl.device_opencl_c_version, true) + return d.get_info_str(device_opencl_c_version, true) } // profile device info - profile pub fn (d &Device) profile() !string { - return d.get_info_str(vcl.device_profile, true) + return d.get_info_str(device_profile, true) } // version device info - version pub fn (d &Device) version() !string { - return d.get_info_str(vcl.device_version, true) + return d.get_info_str(device_version, true) } // driver_version device info - driver version pub fn (d &Device) driver_version() !string { - return d.get_info_str(vcl.driver_version, true) + return d.get_info_str(driver_version, true) } // add_program copiles program source @@ -133,10 +133,9 @@ pub fn (mut d Device) add_program(source string) ! { if ret != success { if ret == build_program_failure { mut n := usize(0) - cl_get_program_build_info(p, d.id, vcl.program_build_log, 0, unsafe { nil }, - &n) + cl_get_program_build_info(p, d.id, program_build_log, 0, unsafe { nil }, &n) log := []u8{len: int(n)} - cl_get_program_build_info(p, d.id, vcl.program_build_log, n, &log[0], unsafe { nil }) + cl_get_program_build_info(p, d.id, program_build_log, n, &log[0], unsafe { nil }) return error(log.bytestr()) } return vcl_error(ret) diff --git a/vcl/errors.c.v b/vcl/errors.c.v index 336cc6070..82fcdafae 100644 --- a/vcl/errors.c.v +++ b/vcl/errors.c.v @@ -7,75 +7,75 @@ const err_unknown = error('vcl_cl: unknown error') pub type ErrVCL = int pub fn (e ErrVCL) err() IError { - if e == vcl.success { + if e == success { return none } err := match e { - vcl.device_not_found { vcl.err_device_not_found } - vcl.device_not_available { vcl.err_device_not_available } - vcl.compiler_not_available { vcl.err_compiler_not_available } - vcl.mem_object_allocation_failure { vcl.err_mem_object_allocation_failure } - vcl.out_of_resources { vcl.err_out_of_resources } - vcl.out_of_host_memory { vcl.err_out_of_host_memory } - vcl.profiling_info_not_available { vcl.err_profiling_info_not_available } - vcl.mem_copy_overlap { vcl.err_mem_copy_overlap } - vcl.image_format_mismatch { vcl.err_image_format_mismatch } - vcl.image_format_not_supported { vcl.err_image_format_not_supported } - vcl.build_program_failure { vcl.err_build_program_failure } - vcl.map_failure { vcl.err_map_failure } - vcl.misaligned_sub_buffer_offset { vcl.err_misaligned_sub_buffer_offset } - vcl.exec_status_error_for_events_in_wait_list { vcl.err_exec_status_error_for_events_in_wait_list } - vcl.compile_program_failure { vcl.err_compile_program_failure } - vcl.linker_not_available { vcl.err_linker_not_available } - vcl.link_program_failure { vcl.err_link_program_failure } - vcl.device_partition_failed { vcl.err_device_partition_failed } - vcl.kernel_arg_info_not_available { vcl.err_kernel_arg_info_not_available } - vcl.invalid_value { vcl.err_invalid_value } - vcl.invalid_device_type { vcl.err_invalid_device_type } - vcl.invalid_platform { vcl.err_invalid_platform } - vcl.invalid_device { vcl.err_invalid_device } - vcl.invalid_context { vcl.err_invalid_context } - vcl.invalid_queue_properties { vcl.err_invalid_queue_properties } - vcl.invalid_command_queue { vcl.err_invalid_command_queue } - vcl.invalid_host_ptr { vcl.err_invalid_host_ptr } - vcl.invalid_mem_object { vcl.err_invalid_mem_object } - vcl.invalid_image_format_descriptor { vcl.err_invalid_image_format_descriptor } - vcl.invalid_image_size { vcl.err_invalid_image_size } - vcl.invalid_sampler { vcl.err_invalid_sampler } - vcl.invalid_binary { vcl.err_invalid_binary } - vcl.invalid_build_options { vcl.err_invalid_build_options } - vcl.invalid_program { vcl.err_invalid_program } - vcl.invalid_program_executable { vcl.err_invalid_program_executable } - vcl.invalid_kernel_name { vcl.err_invalid_kernel_name } - vcl.invalid_kernel_definition { vcl.err_invalid_kernel_definition } - vcl.invalid_kernel { vcl.err_invalid_kernel } - vcl.invalid_arg_index { vcl.err_invalid_arg_index } - vcl.invalid_arg_value { vcl.err_invalid_arg_value } - vcl.invalid_arg_size { vcl.err_invalid_arg_size } - vcl.invalid_kernel_args { vcl.err_invalid_kernel_args } - vcl.invalid_work_dimension { vcl.err_invalid_work_dimension } - vcl.invalid_work_group_size { vcl.err_invalid_work_group_size } - vcl.invalid_work_item_size { vcl.err_invalid_work_item_size } - vcl.invalid_global_offset { vcl.err_invalid_global_offset } - vcl.invalid_event_wait_list { vcl.err_invalid_event_wait_list } - vcl.invalid_event { vcl.err_invalid_event } - vcl.invalid_operation { vcl.err_invalid_operation } - vcl.invalid_gl_object { vcl.err_invalid_gl_object } - vcl.invalid_buffer_size { vcl.err_invalid_buffer_size } - vcl.invalid_mip_level { vcl.err_invalid_mip_level } - vcl.invalid_global_work_size { vcl.err_invalid_global_work_size } - vcl.invalid_property { vcl.err_invalid_property } - vcl.invalid_image_descriptor { vcl.err_invalid_image_descriptor } - vcl.invalid_compiler_options { vcl.err_invalid_compiler_options } - vcl.invalid_linker_options { vcl.err_invalid_linker_options } - vcl.invalid_device_partition_count { vcl.err_invalid_device_partition_count } - vcl.invalid_pipe_size { vcl.err_invalid_pipe_size } - vcl.invalid_device_queue { vcl.err_invalid_device_queue } - vcl.invalid_spec_id { vcl.err_invalid_spec_id } - vcl.max_size_restriction_exceeded { vcl.err_max_size_restriction_exceeded } - vcl.dl_sym_issue { vcl.err_dl_sym_issue } - vcl.dl_open_issue { vcl.err_dl_open_issue } + device_not_found { err_device_not_found } + device_not_available { err_device_not_available } + compiler_not_available { err_compiler_not_available } + mem_object_allocation_failure { err_mem_object_allocation_failure } + out_of_resources { err_out_of_resources } + out_of_host_memory { err_out_of_host_memory } + profiling_info_not_available { err_profiling_info_not_available } + mem_copy_overlap { err_mem_copy_overlap } + image_format_mismatch { err_image_format_mismatch } + image_format_not_supported { err_image_format_not_supported } + build_program_failure { err_build_program_failure } + map_failure { err_map_failure } + misaligned_sub_buffer_offset { err_misaligned_sub_buffer_offset } + exec_status_error_for_events_in_wait_list { err_exec_status_error_for_events_in_wait_list } + compile_program_failure { err_compile_program_failure } + linker_not_available { err_linker_not_available } + link_program_failure { err_link_program_failure } + device_partition_failed { err_device_partition_failed } + kernel_arg_info_not_available { err_kernel_arg_info_not_available } + invalid_value { err_invalid_value } + invalid_device_type { err_invalid_device_type } + invalid_platform { err_invalid_platform } + invalid_device { err_invalid_device } + invalid_context { err_invalid_context } + invalid_queue_properties { err_invalid_queue_properties } + invalid_command_queue { err_invalid_command_queue } + invalid_host_ptr { err_invalid_host_ptr } + invalid_mem_object { err_invalid_mem_object } + invalid_image_format_descriptor { err_invalid_image_format_descriptor } + invalid_image_size { err_invalid_image_size } + invalid_sampler { err_invalid_sampler } + invalid_binary { err_invalid_binary } + invalid_build_options { err_invalid_build_options } + invalid_program { err_invalid_program } + invalid_program_executable { err_invalid_program_executable } + invalid_kernel_name { err_invalid_kernel_name } + invalid_kernel_definition { err_invalid_kernel_definition } + invalid_kernel { err_invalid_kernel } + invalid_arg_index { err_invalid_arg_index } + invalid_arg_value { err_invalid_arg_value } + invalid_arg_size { err_invalid_arg_size } + invalid_kernel_args { err_invalid_kernel_args } + invalid_work_dimension { err_invalid_work_dimension } + invalid_work_group_size { err_invalid_work_group_size } + invalid_work_item_size { err_invalid_work_item_size } + invalid_global_offset { err_invalid_global_offset } + invalid_event_wait_list { err_invalid_event_wait_list } + invalid_event { err_invalid_event } + invalid_operation { err_invalid_operation } + invalid_gl_object { err_invalid_gl_object } + invalid_buffer_size { err_invalid_buffer_size } + invalid_mip_level { err_invalid_mip_level } + invalid_global_work_size { err_invalid_global_work_size } + invalid_property { err_invalid_property } + invalid_image_descriptor { err_invalid_image_descriptor } + invalid_compiler_options { err_invalid_compiler_options } + invalid_linker_options { err_invalid_linker_options } + invalid_device_partition_count { err_invalid_device_partition_count } + invalid_pipe_size { err_invalid_pipe_size } + invalid_device_queue { err_invalid_device_queue } + invalid_spec_id { err_invalid_spec_id } + max_size_restriction_exceeded { err_max_size_restriction_exceeded } + dl_sym_issue { err_dl_sym_issue } + dl_open_issue { err_dl_open_issue } else { 'vcl_cl: error ${e}' } } return error_with_code(err, int(e)) @@ -86,14 +86,14 @@ pub fn error_from_code(code int) IError { } pub fn error_or_default[T](code int, default T) !T { - if code == vcl.success { + if code == success { return default } return ErrVCL(code).err() } pub fn typed_error[T](code int) !T { - if code == vcl.success { + if code == success { return } return ErrVCL(code).err() diff --git a/vcl/image.c.v b/vcl/image.c.v index d06fe7cde..89cd76f9d 100644 --- a/vcl/image.c.v +++ b/vcl/image.c.v @@ -5,7 +5,8 @@ import stbi // Rect is a struct that represents a rectangle shape @[params] pub struct Rect { -pub: // pixel need integers +pub: + // pixel need integers x f32 y f32 width f32 @@ -87,16 +88,16 @@ fn (d &Device) create_image(image_type ImageChannelOrder, bounds Rect, row_pitch buf := &Buffer{ memobj: memobj - size: size + size: size device: d } img := &Image{ - buf: buf - bounds: bounds - @type: image_type - format: format - desc: desc + buf: buf + bounds: bounds + @type: image_type + format: format + desc: desc img_data: data } if !isnil(data) { @@ -114,10 +115,10 @@ pub fn (image &Image) data() !IImage { region, 0, 0, unsafe { &read_image_result[0] }, 0, unsafe { nil }, unsafe { nil }) nb_channels := if image.@type == ImageChannelOrder.rgba { 4 } else { 1 } img := stbi.Image{ - width: int(image.bounds.width) - height: int(image.bounds.height) + width: int(image.bounds.width) + height: int(image.bounds.height) nr_channels: nb_channels - data: unsafe { &read_image_result[0] } + data: unsafe { &read_image_result[0] } } return error_or_default(ret, IImage(img)) } diff --git a/vcl/internal/dl/dl.c.v b/vcl/internal/dl/dl.c.v index 884ebe5bc..ee38c1c20 100644 --- a/vcl/internal/dl/dl.c.v +++ b/vcl/internal/dl/dl.c.v @@ -10,9 +10,9 @@ pub const dl_register_issue_code = loader.dl_register_issue_code fn get_or_create_dynamic_lib_loader() !&loader.DynamicLibLoader { return loader.get_or_create_dynamic_lib_loader( - key: @MOD + '.' + 'LibOpenCL' + key: @MOD + '.' + 'LibOpenCL' env_path: 'VCL_LIBOPENCL_PATH' - paths: default_paths + paths: default_paths ) } diff --git a/vcl/kernel.c.v b/vcl/kernel.c.v index f87a1d604..671c061e2 100644 --- a/vcl/kernel.c.v +++ b/vcl/kernel.c.v @@ -53,7 +53,7 @@ pub struct Kernel { // global returns an kernel with global size set pub fn (k &Kernel) global(global_work_sizes ...int) KernelWithGlobal { return KernelWithGlobal{ - kernel: unsafe { k } + kernel: unsafe { k } global_work_sizes: global_work_sizes } } @@ -68,9 +68,9 @@ pub struct KernelWithGlobal { // local ets the local work sizes and returns an KernelCall which takes kernel arguments and runs the kernel pub fn (kg KernelWithGlobal) local(local_work_sizes ...int) KernelCall { return KernelCall{ - kernel: kg.kernel + kernel: kg.kernel global_work_sizes: kg.global_work_sizes - local_work_sizes: local_work_sizes + local_work_sizes: local_work_sizes } } diff --git a/vcl/vcl.c.v b/vcl/vcl.c.v index aea5936ae..712f9798c 100644 --- a/vcl/vcl.c.v +++ b/vcl/vcl.c.v @@ -31,8 +31,7 @@ pub fn get_devices(device_type DeviceType) ![]&Device { pub fn get_default_device() !&Device { mut id := ClDeviceId(0) platform_ids := get_platforms()! - ret := cl_get_device_i_ds(unsafe { &platform_ids[0] }, ClDeviceType(DeviceType.cpu), - 1, &id, unsafe { nil }) + ret := cl_get_device_i_ds(platform_ids[0], ClDeviceType(DeviceType.cpu), 1, &id, unsafe { nil }) if ret != success { return error_from_code(ret) }