VSL Examples Collection ๐Ÿ“š

June 1, 2026 ยท View on GitHub

Welcome to the VSL Examples Directory! This comprehensive collection demonstrates the full capabilities of the V Scientific Library through practical, well-documented examples. Each example is designed to showcase specific features while providing clear learning paths for both beginners and advanced users.

๐ŸŽฏ Quick Start Guide

Prerequisites

  1. V Compiler: Download from vlang.io
  2. VSL Library: Follow the installation guide
  3. Optional Dependencies: Some examples require additional libraries (documented per example)

Running Examples

# From ~/.vmodules or the repository parent
v run vsl/examples/plot_scatter/main.v

# Or from inside an example directory
cd vsl/examples/plot_scatter
v run main.v

# For examples with custom dependencies
v -cflags <flags> run main.v

๐Ÿ“– Learning Path

Beginners: Start with โ†’ plot_scatter โ†’ plot_line_timeseries โ†’ plot_bar โ†’ data_analysis_example

Intermediate: Explore โ†’ plot_box_statistics โ†’ plot_violin_distributions โ†’ ml_linreg_plot โ†’ fft_plot_example

Advanced Plotting: Try โ†’ plot_sunburst_hierarchy โ†’ plot_choropleth_population โ†’ plot_sankey_energy โ†’ plot_json_export

Machine Learning: Progress โ†’ ml_kmeans โ†’ ml_linreg_plot โ†’ ml_complete_pipeline โ†’ ml_sentiment_analysis

Scientific Computing: Dive into โ†’ fft_plot_example โ†’ deriv_example โ†’ mpi_basic_example

Machine Learning Examples ๐Ÿค–

ExampleDescription
ml_kmeansExample demonstrating the K-means clustering algorithm.
ml_sentiment_analysisExample for sentiment analysis using machine learning.
ml_linreg01Basic linear regression example.
ml_linreg02Advanced linear regression example.
ml_linreg_plotLinear regression with plotting.
ml_kmeans_plotK-means clustering with plotting.
ml_knn_plotK-Nearest Neighbors algorithm with plotting.
ml_logregLogistic regression for binary classification.
ml_svmSupport Vector Machine with kernel functions.
ml_decision_treeDecision tree for classification and regression.
ml_random_forestRandom Forest ensemble learning.
ml_complete_pipelineEnd-to-end preprocessing, model selection, and metrics.

Plotting Examples ๐Ÿ“Š

Core Plot Types

ExampleDescription
plot_scatterBasic scatter plot example.
plot_line_timeseriesTime series line chart plotting.
plot_barBasic bar plot example.
plot_histogramExample showing how to create a histogram.
plot_piePie chart plotting example.
plot_basic_heatmapBasic heatmap example.
plot_heatmap_golden_ratioHeatmap example with the golden ratio.
plot_scatter3d_13D scatter plot example 1.
plot_scatter3d_23D scatter plot example 2.
plot_scatter3d_easing3D scatter plot with easing.
plot_saddle_surfacePlotting a saddle surface.
plot_ripple_surfacePlotting a ripple surface.
plot_sin_cos_surfacePlotting the sine and cosine surface.
plot_surface3D surface plotting example.
plot_surface_easing3D surface with animation easing.

Statistical & Distribution Charts

ExampleDescription
plot_box_statisticsBox plot for statistical analysis.
plot_violin_distributionsViolin plot for distribution visualization.
plot_contour_topographyContour plot for topographical data.
plot_histogram2d_correlation2D histogram for correlation analysis.

Business & Financial Charts

ExampleDescription
plot_waterfall_financialWaterfall chart for financial analysis.
plot_candlestick_stocksCandlestick chart for stock data.
plot_ohlc_market_regimeOHLC chart for market regime analysis.
plot_funnel_conversionFunnel chart for conversion analysis.
plot_table_executive_summaryKPI summary table for executive dashboards.

Hierarchical & Network Charts

ExampleDescription
plot_sunburst_hierarchySunburst chart for hierarchical data.
plot_treemap_portfolioTreemap chart for portfolio visualization.
plot_sankey_energySankey diagram for energy flow analysis.

Advanced Analytics

ExampleDescription
plot_radar_performanceRadar chart for multi-dimensional analysis.
plot_parcoords_analysisParallel coordinates for high-dimensional data.

Geographic & Mapping

ExampleDescription
plot_choropleth_populationChoropleth map for geographic data.
plot_scattermapbox_citiesScatter plot on mapbox for location data.

Export & Automation

ExampleDescription

Styling & Customization

ExampleDescription
plot_line_axis_titlesLine plot with axis titles.
plot_scatter_with_annotationsScatter plot with annotations.
plot_annotated_pie_chartAnnotated pie chart example.
plot_grouped_bar_chartGrouped bar chart plotting example.
plot_scatter_with_barsScatter plot with bars.
plot_line_plot_with_areasLine plot with shaded areas.
plot_scatter_with_regressionScatter plot with regression line.
plot_bubble_chartBubble chart plotting example.
plot_shaded_area_sinShaded area plot of the sine function.
plot_scatter_easingScatter plot with animation easing.
plot_scatter_colorscaleScatter plot with custom color scaling.
plot_scatter_annotations_fixedClean annotations without unwanted arrows.
plot_scatter_with_histogramScatter plot combined with histogram.
plot_json_exportExport plot data to JSON format.

Script Mode Examples

ExampleDescription
plot_script_mode_ac_signalAC signal plotting in script mode.
plot_script_mode_simple_plotSimple plot in script mode.
plot_script_mode_three_phase_signalThree-phase signal plotting in script mode.

BLAS & LAPACK Examples ๐Ÿš€

ExampleDescription
blas_basic_operationsBasic BLAS operations (Level 1, 2, 3) - vector and matrix ops.
blas_performance_comparisonPerformance benchmarking of BLAS operations.
lapack_linear_systemsSolving linear systems using LAPACK (dgesv, dgetrf, dpotrf).
lapack_eigenvalue_problemsEigenvalue decomposition using LAPACK (dsyev).

Mathematical and Scientific Computation Examples ๐Ÿ”ข

ExampleDescription
fft_plot_exampleExample demonstrating Fast Fourier Transform (FFT) with plotting.
diff_exampleDifferentiation example.
poly_examplesCore polynomial operations and root solvers.
prime_examplesPrime module usage: primality checks and sieve.
easings_motion_profilesKinematic analysis of representative easing motion profiles.
easings_signal_shapingADSR-like signal envelope shaping with easing functions.
../fit/examples/line_calibrationLinear fit for sensor calibration and residual analysis.
../fit/examples/trend_qualityLinear fit with uncertainty, chi-square, and RMSE inspection.
prime_factorizationPrime factorization example.
roots_bisection_solverRoot finding using the bisection method.
deriv_exampleDerivative calculation example.
graph_shortest_paths_methodsCompare FW, Dijkstra, and BFS shortest-path strategies.

Geometry Module Examples ๐Ÿ“

ExampleDescription
gm_basic_geometryFundamental 3D geometry operations.
gm_advanced_analysisAdvanced geometric analysis techniques.
gm_distance_analysisDistance calculation and shape analysis.
gm_spatial_binningSpatial indexing and binning systems.
gm_geometry_playgroundInteractive geometry exploration.
gm_trajectory_simulationMotion and trajectory analysis.

Quaternion Examples ๐Ÿ”„

ExampleDescription
quaternion_rotation_3dVisualize 3D rotations using quaternions and plotting.
quaternion_interpolation_animationAnimated quaternion interpolation visualization.
quaternion_julia_fractalQuaternion Julia set fractal visualization.
quaternion_orientation_trackingTrack object orientation over time with visualization.
quaternion_rotation_compositionCompose multiple rotations and visualize the path.
quaternion_camera_lookCamera yaw/pitch composition and lock-on blending.
quaternion_turret_trackingTurret tracking with angular-error interpolation checks.

Library Integration Examples ๐Ÿ”—

ExampleDescription
ml_quaternion_featuresUse quaternions as ML features for clustering.
fft_quaternion_signalProcess quaternion-valued signals and visualize.
geometry_ml_clusteringCombine geometry module with ML clustering.
lapack_plot_eigenvaluesVisualize eigenvalue problems solved with LAPACK.
noise_quaternion_fractalCombine quaternions and noise for textured fractals.

GPU / Accelerator Examples โšก

ExampleDescription
vcl_opencl_basicBasic OpenCL/VCL device and kernel usage.
vcl_opencl_kernel_paramsOpenCL kernel parameter handling.
vcl_opencl_image_exampleOpenCL image processing example.
vcl_opencl_fractals_one_argumentFractal compute workload with OpenCL.

CUDA and Vulkan backend smoke tests live under cuda/ and vulkan/, because they are backend-level validation rather than end-user examples.

Noise & Signal Processing Examples ๐ŸŒŠ

ExampleDescription
noise_fractal_2d2D fractal noise generation.
noise_simplex_2d2D simplex noise generation.

Data Analysis Examples ๐Ÿ“ˆ

ExampleDescription
data_analysis_exampleBasic data analysis example.
io_h5_relaxExample demonstrating HDF5 I/O for relaxation data.
io_h5_datasetExample demonstrating HDF5 I/O for datasets.

Iteration and Lazy Generation Examples ๐Ÿ”„

ExampleDescription
iter_lazy_generationExample of lazy generation using iterators.

Parallel and Distributed Computing Examples ๐ŸŒ

ExampleDescription
mpi_bcast_exampleExample demonstrating MPI broadcast.
mpi_basic_exampleBasic MPI example.

OpenCL Examples ๐Ÿ–ฅ๏ธ

ExampleDescription
vcl_opencl_fractals_one_argumentFractal generation using OpenCL.
vcl_opencl_image_exampleImage processing using OpenCL.
vcl_opencl_basicBasic OpenCL example.

Miscellaneous Examples ๐ŸŒŸ

ExampleDescription
la_triplet01Example demonstrating linear algebra operations.
dist_histogramDistribution histogram example.

๐Ÿ“‹ Important Guidelines โš ๏ธ

Total Examples: This collection includes 85+ working examples covering all VSL modules.

  • Documentation First: Each example includes a detailed README.md - always read it before running
  • Dependencies: Check for system requirements in individual example READMEs
  • Output: Examples may generate plots, files, or terminal output - check the documentation for expected results
  • Troubleshooting: If an example fails, verify all prerequisites are installed and refer to the main VSL documentation

๐Ÿ”ง Building & Compilation

Most examples work with standard compilation:

v run main.v

For performance-critical examples with optional backends:

# With OpenBLAS
v -cflags -lblas run main.v

# With OpenMPI
v -cflags -lmpi run main.v

๐Ÿค Contributing Examples

We welcome new examples! Please ensure your contributions:

  • Include comprehensive documentation
  • Follow existing naming conventions
  • Provide clear, commented code
  • Include expected output samples
  • Test across different platforms

See the Contributing Guide for detailed guidelines.