### Start Calcpad CLI on Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Launches the Calcpad command-line interpreter (CLI) for performing calculations in console mode. ```bash calcpad ``` -------------------------------- ### Install Calcpad on Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Installs Calcpad using the downloaded .deb package. Replace `` with the actual path to the downloaded file. ```bash sudo apt-get install -y /Calcpad.7.5.6.deb ``` ```bash sudo apt-get install -y /home/ned/snap/chromium/3235/Downloads/Calcpad.7.5.6.deb ``` -------------------------------- ### Install .NET 10.0 Runtime on Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Installs the .NET 10.0 runtime required for Calcpad. It first updates package lists and then installs the runtime. An optional command to remove older .NET versions is also provided. ```bash sudo apt update sudo apt-get install -y dotnet-runtime-10.0 ``` ```bash sudo apt remove dotnet* sudo apt update sudo apt-get install -y dotnet-runtime-10.0 ``` -------------------------------- ### Python API - Complete Example Source: https://context7.com/proektsoftbg/calcpad/llms.txt An interactive calculator example demonstrating error handling and continuous evaluation capabilities. ```APIDOC ## Python API - Complete Example ### Description An interactive calculator example demonstrating error handling and continuous evaluation capabilities. ### Usage ```python from PyCalcpadWrapper import Calculator, MathSettings from termcolor import colored import os # Initialize calculator os.system("color") # Enable terminal colors on Windows settings = MathSettings() settings.Decimals = 15 calc = Calculator(settings) # Example usage (further implementation needed for interactive loop) ``` ``` -------------------------------- ### Launch Sublime Text and Chromium on Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Starts Sublime Text and Chromium browsers in the background. This is useful for side-by-side development and viewing Calcpad calculation results. ```bash subl & chromium & ``` -------------------------------- ### Install Chromium Browser on Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Installs the Chromium web browser using snap. Chromium is needed to download Calcpad and view calculation reports. ```bash sudo snap install chromium ``` -------------------------------- ### Install Sublime Text on Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Installs Sublime Text editor on Ubuntu by adding its GPG key and repository, then installing the package. This setup allows for writing and executing Calcpad code. ```bash wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null sudo apt-get update echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list sudo apt-get install sublime-text ``` -------------------------------- ### Define Derived Custom Units (Example) Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Shows how to define custom units that are derived from other units, including custom ones. This example illustrates defining 'bit', 'byte', and 'KiB' units, where each subsequent unit is a multiple of the previous one. ```Calcpad ._bit_ = 1 ._byte_ = 8*_bit_ ._KiB_ = 1024*_byte_ ``` -------------------------------- ### Complete Calculator Example (Python) Source: https://context7.com/proektsoftbg/calcpad/llms.txt Demonstrates an interactive calculator with error handling and continuous evaluation capabilities. Initializes the Calculator class with specified math settings. ```python from PyCalcpadWrapper import Calculator, MathSettings from termcolor import colored import os # Initialize calculator os.system("color") settings = MathSettings() settings.Decimals = 15 calc = Calculator(settings) ``` -------------------------------- ### Deploy Calcpad.WebApi using Docker Compose Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.WebApi/README.md Deploys the Calcpad.WebApi service using Docker Compose. This involves navigating to the deployment directory, configuring settings, and starting the service in detached mode. ```bash cd ~/app/calcpad sudo docker compose up -d ``` -------------------------------- ### Calcpad Expressions Examples Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Demonstrates basic mathematical expressions that Calcpad can evaluate. Expressions are line-based and do not require an assignment operator unless defining variables. Results are shown after pressing the 'Play' button. ```Calcpad 2 + 3 5*(3+1) 15/2 ``` -------------------------------- ### GET /api/v1/calcpad-file/{uniqueId}/origin Source: https://context7.com/proektsoftbg/calcpad/llms.txt Downloads the original Calcpad file along with all its dependencies (includes) packaged as a ZIP archive. ```APIDOC ## GET /api/v1/calcpad-file/{uniqueId}/origin ### Description Downloads the specified Calcpad file and all its included dependencies as a ZIP archive. ### Method GET ### Endpoint `/api/v1/calcpad-file/{uniqueId}/origin` ### Parameters #### Path Parameters - **uniqueId** (string) - Required - The unique identifier of the Calcpad file to download. #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer YOUR_TOKEN`). ### Request Example ```bash curl -X GET "http://localhost:5098/api/v1/calcpad-file/calc-001/origin" \ -H "Authorization: Bearer YOUR_TOKEN" \ -o "calculation.zip" ``` ### Response #### Success Response (200) - The response body will contain the ZIP archive of the Calcpad file and its dependencies. ``` -------------------------------- ### Get User Input in C++ Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html A C++ code snippet demonstrating how to prompt the user for input and store it. It uses standard input/output streams and requires the `` header. The input is expected to be a string. ```cpp #include #include int main() { std::string userName; std::cout << "Enter your name: "; std::cin >> userName; std::cout << "Hello, " << userName << "!\n"; return 0; } ``` -------------------------------- ### Custom Function Call Example Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Example of calling a user-defined function in Calcpad. Arguments must match the number of parameters defined for the function. Function names must follow variable naming rules, and library functions cannot be redefined. ```Calcpad b = g(a + 2; 3) + 3 ``` -------------------------------- ### Create Empty Upper Triangular Matrix Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Initializes an n x n upper triangular matrix with all elements set to zero. Subsequent filling with values, for example using `mfill`, will populate the upper triangle. ```calcpad **utriang**(n) ``` -------------------------------- ### Create Empty Lower Triangular Matrix Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Initializes an n x n lower triangular matrix with all elements set to zero. Subsequent filling with values, for example using `mfill`, will populate the lower triangle. ```calcpad **ltriang**(n) ``` -------------------------------- ### Calcpad Relational and Logical Operators Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Shows examples of relational (comparison) and logical operators in Calcpad. Relational operators include equal to, unequal to, less than, greater than, less than or equal to, and greater than or equal to. Logical operators include AND, OR, and XOR, with available shortcuts. ```Calcpad // Relational Operators equal = 5 == 5 // Equal to (shortcut: ==) unequal = 5 != 3 // Unequal to (shortcut: !=) less_than = 5 < 10 greater_than = 10 > 5 less_equal = 5 <= 5 // Less or equal (shortcut: <=) greater_equal = 10 >= 5 // Greater or equal (shortcut: >=) // Logical Operators logical_and = true && false // Logical AND (shortcut: &&) logical_or = true || false // Logical OR (shortcut: ||) logical_xor = true ^^ false // Logical XOR (shortcut: ^^) ``` -------------------------------- ### Data Fetching and Rendering Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html This snippet demonstrates fetching data from a source and then rendering it. It's a common pattern in web applications where data is retrieved (e.g., from an API or database) and then displayed to the user. Error handling is included for robustness. ```javascript async function fetchDataAndRender(url) { try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } const data = await response.json(); renderData(data); } catch (error) { console.error('Error fetching or rendering data:', error); displayError('Failed to load data.'); } } function renderData(data) { console.log('Rendering data:', data); // Logic to update the DOM with the fetched data } function displayError(message) { console.error('Displaying error:', message); // Logic to show an error message to the user } ``` -------------------------------- ### Example: Parametric Plot of a Rose Curve Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Demonstrates plotting a parametric curve, specifically a rose curve, using the $Plot command. The equation for the radius r(θ) is given, and then used to define the x and y components as functions of θ. ```calcpad r(θ) = cos(5/2*θ) $Plot{r(θ)*cos(θ)|r(θ)*sin(θ) @ θ = 0:6*π} ``` -------------------------------- ### Configuration Loading Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html This snippet shows a method for loading configuration settings. It likely reads from a file or environment variables to set up application parameters. This is crucial for managing different environments and settings. ```javascript const fs = require('fs'); const path = require('path'); function loadConfig(env) { const configPath = path.join(__dirname, `config.${env}.json`); try { const configFile = fs.readFileSync(configPath, 'utf-8'); return JSON.parse(configFile); } catch (error) { console.error(`Error loading config for environment ${env}:`, error); // Fallback to default or throw error return loadConfig('default'); // Example fallback } } // Example usage: // const environment = process.env.NODE_ENV || 'development'; // const config = loadConfig(environment); // console.log('Loaded configuration:', config); ``` -------------------------------- ### Settings Classes Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Python/Readme.md Allows configuration of mathematical, plotting, and general settings for calculations. ```APIDOC ## Settings Classes ### Description Allows configuration of mathematical, plotting, and general settings for calculations. ### Classes #### `Settings` - **Description**: Manages overall settings for calculations. - **Methods**: - `Settings()`: Creates a new 'Settings' object with default values. - **Properties**: - `Math` (MathSettings): Reads or assigns the math settings object. - `Plot` (PlotSettings): Reads or assigns the plot settings object. - `Units` (str): Specifies units to replace '%u' in comments (e.g., 'm', 'cm', 'mm'). Defaults to 'm'. #### `MathSettings` - **Description**: Configures mathematical calculation settings. - **Methods**: - `MathSettings()`: Creates a new 'MathSettings' object with default values. - **Properties**: - `Decimals` (int): Number of digits after the decimal point (0-15). Defaults to 2. - `Degrees` (TrigUnits): Default units for trigonometric functions (Deg, Rad, Grad). Defaults to `TrigUnits.Deg`. - `IsComplex` (bool): Enables complex number calculations if True. Defaults to False. - `Substitute` (bool): Switches variable substitution in output on (True) or off (False). Defaults to True. - `FormatEquations` (bool): Specifies if equations are formatted in professional or linear styles. Defaults to True. - `ZeroSmallMatrixElements` (bool): Sets small vector/matrix elements (< 10^-14 times max. element magnitude) to be displayed as zeros. Defaults to True. - `MaxOutputCount` (int): Sets the maximum number of elements displayed in vector or matrix rows/columns (5-100). Defaults to 20. #### `PlotSettings` - **Description**: Configures plot generation settings. - **Methods**: - `PlotSettings()`: Creates a new 'PlotSettings' object with default values. - **Properties**: - `IsAdaptive` (bool): Enables adaptive plotting based on function curvature. Defaults to True. - `VectorGraphics` (bool): Specifies if plots are generated as vector (SVG) or raster (PNG) images. Defaults to False. - `ColorScale` (ColorScales): Sets the color scale for surface plots. Defaults to `ColorScales.Rainbow`. - `SmoothScale` (bool): If True, scale colors fuse as a smooth gradient; otherwise, uniform isobands are displayed. Defaults to False. - `Shadows` (bool): Specifies if surface plots display with shadows (Blinn-Phong shading). Defaults to True. - `LightDirection` (LightDirections): Sets the direction of the light source for shading. Defaults to `LightDirections.NorthWest`. ``` -------------------------------- ### Rounding Function Examples Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Examples demonstrating the behavior of rounding functions (round, floor, ceiling, trunc) for both positive and negative numbers. These functions affect the real and imaginary parts of complex numbers. ```Calcpad round(4.5) // Result: 5 floor(4.8) // Result: 4 ceiling(4.2) // Result: 5 trunc(4.8) // Result: 4 round(-4.5) // Result: -5 floor(-4.8) // Result: -5 ceiling(-4.2) // Result: -4 trunc(-4.8) // Result: -4 ``` -------------------------------- ### Send HTTP Request in Python Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html Python script to send an HTTP GET request to a specified URL. It utilizes the `requests` library for making the request and prints the status code of the response. The URL is the primary input. ```python import requests url = "https://api.example.com/data" response = requests.get(url) print(f"Status Code: {response.status_code}") ``` -------------------------------- ### Configure Database Connection in Java Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html Java code snippet for establishing a database connection using JDBC. It specifies the connection URL, username, and password. Error handling for `SQLException` is included. This requires the JDBC driver for the specific database. ```java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DbConnection { private static final String URL = "jdbc:mysql://localhost:3306/mydatabase"; private static final String USER = "user"; private static final String PASSWORD = "password"; public static Connection getConnection() throws SQLException { return DriverManager.getConnection(URL, USER, PASSWORD); } } ``` -------------------------------- ### Style an HTML Element with CSS Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html CSS code to style an HTML element with the class `highlight`. It sets the text color to blue and adds a border. This is a basic example of cascading style sheets. ```css .highlight { color: blue; border: 1px solid black; } ``` -------------------------------- ### Get File Paths from Calcpad File (cURL) Source: https://context7.com/proektsoftbg/calcpad/llms.txt Retrieves a list of all file paths referenced within a specified Calcpad file using a GET request to the API. Requires an authorization token. ```shell curl -X GET "http://localhost:5098/api/v1/calcpad-file/calc-001/file-paths" \ -H "Authorization: Bearer YOUR_TOKEN" ``` -------------------------------- ### Sign In to Calcpad.WebApi Service Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.WebApi/README.md Illustrates the initial step for integrating with the Calcpad.WebApi service, which involves obtaining an authentication token by signing in. This token is necessary for subsequent API calls. ```http /api/v1/user/sign-in ``` -------------------------------- ### C++ Mathematical Operations and Control Flow Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/Bulgarian/Html/parsing.bg.html This C++ snippet showcases fundamental mathematical operations and control flow structures. It includes examples of arithmetic operations, conditional statements (if-else), and potentially loop constructs, forming the core logic for calculations. ```cpp double calculate_area(double radius) { const double PI = 3.14159; if (radius < 0) { return -1; // Indicate error } return PI * radius * radius; } void process_data(int value) { if (value > 100) { // Process large value } else if (value > 50) { // Process medium value } else { // Process small value } } ``` -------------------------------- ### Calcpad Interpolation Function Examples Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Illustrates Calcpad's interpolation functions ('take', 'line', 'spline') which require a scalar for the interpolation variable as the first argument. These functions can also accept mixed lists of arguments, similar to aggregate functions. Examples show interpolation on a vector and mixed lists. ```calcpad a = [0; 2; 6] take(3; a) ``` ```calcpad a = [0; 2; 6] line(1.5; a) ``` ```calcpad a = [0; 2; 6] spline(1.5; a) ``` ```calcpad a = [1; 2; 3] b = [5; 6; 7; 8] take(7; a; 4; b; 9; 10) ``` -------------------------------- ### File Download API - Download Origin File Source: https://context7.com/proektsoftbg/calcpad/llms.txt Downloads the original Calcpad file (.cpd) along with all its included dependencies as a ZIP archive. Requires an authorization token and the unique ID of the file. The output can be redirected to a file. ```bash curl -X GET "http://localhost:5098/api/v1/calcpad-file/calc-001/origin" \ -H "Authorization: Bearer YOUR_TOKEN" \ -o "calculation.zip" ``` -------------------------------- ### add Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Adds elements from a source matrix (A) to a destination matrix (B) starting at specified indices (i, j). ```APIDOC ## add ### Description Adds elements from a source matrix (A) to a destination matrix (B) starting at specified indices (i, j). ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **A** (matrix) - The source matrix. - **B** (matrix) - The destination matrix. - **i** (integer) - The starting row index in matrix B (1-based). - **j** (integer) - The starting column index in matrix B (1-based). ### Request Example ``` # Example for add function would go here, similar to copy. ``` ### Response #### Success Response (Return Value) - **matrix** (matrix) - The destination matrix B after addition. ``` -------------------------------- ### Search Matrix Elements Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Searches for the first occurrence of a value in a matrix starting from a specified row and column index. ```APIDOC ## MSEARCH ### Description Searches for the first occurrence of a value `x` in matrix `M`, starting the search from row `i` and column `j` (inclusive). The search proceeds row by row, from left to right. If the value is not found, `[0 0]` is returned. ### Method N/A (This is a function call within the Calcpad environment) ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ``` A = [1; 2; 3|1; 5; 6|1; 8; 9] b = msearch(A; 1; 1; 1) # b will be [1 1] c = msearch(A; 1; 2; 2) # c will be [3 1] d = msearch(A; 4; 1; 1) # d will be [0 0] ``` ### Response #### Success Response (200) N/A (Function return value) #### Response Example ```json { "return_value": "[row_index column_index]" } ``` ``` -------------------------------- ### JavaScript Functions for DOM Manipulation and Input Handling Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Cli/doc/template.zh.html This snippet includes several JavaScript functions designed to interact with the Document Object Model (DOM). It covers getting vertical positions of elements, checking for numeric input, retrieving HTML content with input values, extracting target IDs, and getting values from input fields or elements. These functions are crucial for dynamic page updates and form handling. ```javascript function getVerticalPosition(line) { return document.querySelector("[data-text='" + line + "']").getBoundingClientRect().top; } function isNumeric(s) { return s.match(/^-?\d+(?:\.\d+)?$/); } if (window.jQuery) { function getHtmlWithInput() { $("input[type=text]").each(function () { $(this).attr("value", $(this).val()); }); $("input[type=hidden]").each(function () { $(this).attr("value", $(this).val()); }); $("textarea").each(function () { $(this).html($(this).val()); }); $("input[type=radio]").each(function () { if (this.checked) $(this).attr("checked", "checked"); else $(this).removeAttr("checked"); }); $("input[type=checkbox]").each(function () { if (this.checked) $(this).attr("checked", "checked"); else $(this).removeAttr("checked"); }); $("select option").each(function () { if (this.selected) { $(this).attr("selected", "true"); } else $(this).removeAttr("selected"); }); return document.body.outerHTML; } function getTargetId(element) { var id = $(element).attr("name"); if (id != null && id.length > 0) return id; return $(element).data("target"); } function getValue(id, source) { var value = ""; var target = $("#" + id + " input"); var domObj = target.get(0); if (domObj == null || domObj.Length == 0) { target = $("#" + id + " .eq u"); target.each(function () { value += $(this).text() + ";"; }); $(source).prop('disabled', true); } else { target.each(function () { value += $(this).val() + ";"; }); } if (value.length > 1) { value = value.slice(0, -1); } return value; } $(document).ready(function () { $(".dvcs:has(.block) > :first-child").html(" "); $("#Units").change(function () { $(".Units").text($(this).val()); }); $(".fold > :first-child").click(function () { if ($(this).parent().hasClass("fold")) { $(this).parent().removeClass("fold").addClass("unfold"); } else { $(this).parent().removeClass("unfold").addClass("fold"); } }); $("select").each(function (index) { if ($(this).prop("id") != "Units") { var id = getTargetId(this); if (id != null && id.length > 0) { var value = getValue(id, this); $(this).val(value); } } }); $("select").change(funct ``` -------------------------------- ### Calcpad: Write Matrix to File Command Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Demonstrates the basic syntax for writing a matrix 'M' to a specified file. Assumes default settings if not otherwise configured. ```calcpad #write M to _filename.txt_ ``` -------------------------------- ### copy Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Copies elements from a source matrix (A) to a destination matrix (B) starting at specified indices (i, j). Modifies B in place. ```APIDOC ## copy ### Description Copies elements from a source matrix (A) to a destination matrix (B) starting at specified indices (i, j). Modifies B in place. ### Method N/A (Function Call) ### Endpoint N/A (Function Call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **A** (matrix) - The source matrix. - **B** (matrix) - The destination matrix. - **i** (integer) - The starting row index in matrix B (1-based). - **j** (integer) - The starting column index in matrix B (1-based). ### Request Example ``` A = [1; 2; 3|4; 5; 6] B = mfill(matrix(3; 4); -1) copy(A; B; 1; 1) copy(A; B; 2; 2) ``` ### Response #### Success Response (Return Value) - **matrix** (matrix) - The destination matrix B after copying. ``` -------------------------------- ### Calcpad: Read Matrix from File Command Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Demonstrates the basic syntax for reading a matrix 'M' from a specified file. Assumes default settings if not otherwise configured. ```calcpad #read M from _filename.txt_ ``` -------------------------------- ### Get Number of Columns in a Matrix - Calcpad Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html The n_cols function returns the total number of columns in a given matrix. This is a structural property of the matrix. ```calcpad **n_cols**(M) ``` -------------------------------- ### Database Query Execution Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/parsing.zh.html This snippet outlines the process of executing a database query. It likely uses a database client library to connect to a database, run a query, and return the results. Proper error handling and resource management are important here. ```javascript const dbClient = require('./dbClient'); // Assuming a db client module async function executeQuery(sqlQuery, params = []) { let connection; try { connection = await dbClient.getConnection(); const [rows] = await connection.execute(sqlQuery, params); console.log('Query executed successfully.'); return rows; } catch (error) { console.error('Error executing database query:', error); throw error; // Re-throw to be handled by the caller } finally { if (connection) { connection.release(); // Release connection back to pool } } } // Example usage: // const query = 'SELECT * FROM users WHERE id = ?'; // executeQuery(query, [123]).then(results => console.log(results)).catch(err => console.error(err)); ``` -------------------------------- ### Get Number of Rows in a Matrix - Calcpad Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html The n_rows function returns the total number of rows in a given matrix. This is a structural property of the matrix. ```calcpad **n_rows**(M) ``` -------------------------------- ### Using Notepad++ for Calcpad Syntax Highlighting Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html This section explains how to integrate Calcpad's syntax highlighting into Notepad++. It involves downloading a predefined XML file and importing it through Notepad++'s language definition menu. This enhances the editing experience for Calcpad scripts within Notepad++. ```text 1. Download the Calcpad-syntax-for-Notepad++.xml file from https://calcpad.eu/download/Notepadpp.zip. 2. Open Notepad++. 3. Go to the "Language" menu. 4. Select "Define your language". 5. Click "Import…". 6. Navigate to your Calcpad installation directory (usually in "Program Files") and select the imported XML file. ``` -------------------------------- ### Get Vector Length in Calcpad Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html The 'len(vector)' function returns the total number of elements in a vector, representing its full mathematical length. ```Calcpad len([1; 0; 2; 3]) ' 4 ``` -------------------------------- ### Package WebApi Project with zip.ps1 Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.WebApi/README.md Packages the WebApi project and its dependencies into a zip archive for deployment. This PowerShell script is essential for creating a deployable artifact. ```powershell # run packaging script ./zip.ps1 ``` -------------------------------- ### Get Number of Matrix Columns Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html The n_cols function returns the total number of columns in a given matrix. This is essential for matrix dimension analysis. ```Calcpad **n_cols**([1|2; 3|4; 5; 6]) ``` -------------------------------- ### Calcpad Unit Operations and Conversions Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Demonstrates how to use Calcpad for unit-based calculations, including addition with different units, target unit specification, and unit conversion. It also shows how to define variables with units and perform calculations involving unit conversions. ```Calcpad 'Distance -'s_1 = 50_m_ 'Time -'t_1 = 2_s_ 'Speed -'V = s_1/t_1|_km_/_h_ 'What distance you will travel for't_2 = 5_s_'? s_2 = V*t_2|_m_ ``` -------------------------------- ### Calcpad For Loop Block Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Iterates over a specified range for a counter variable. The loop executes for each value of the counter from the start to the end value. ```Calcpad Script #For counter = start : end Code to be executed repeatedly #Loop ``` -------------------------------- ### Get Number of Matrix Rows Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html The n_rows function returns the total number of rows in a given matrix. This is a fundamental operation for understanding matrix dimensions. ```Calcpad **n_rows**([1; 2|3; 4|5; 6]) ``` -------------------------------- ### GET /api/v1/calcpad-file/input-form Source: https://context7.com/proektsoftbg/calcpad/llms.txt Generates an HTML input form for a Calcpad worksheet. It can automatically detect input fields. ```APIDOC ## GET /api/v1/calcpad-file/input-form ### Description Generates an HTML form for user input based on a Calcpad worksheet. ### Method GET ### Endpoint `/api/v1/calcpad-file/input-form` ### Parameters #### Query Parameters - **uniqueId** (string) - Required - The unique identifier of the Calcpad file. - **simplify** (boolean) - Optional - If `true`, the form will be simplified. Defaults to `false`. #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer YOUR_TOKEN`). ### Request Example ```bash curl -X GET "http://localhost:5098/api/v1/calcpad-file/input-form?uniqueId=calc-001&simplify=true" \ -H "Authorization: Bearer YOUR_TOKEN" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the form generation was successful. - **data** (string) - The generated HTML containing input elements. - **message** (string) - Any message associated with the response. #### Response Example ```json { "success": true, "data": "
...
", "message": "" } ``` ``` -------------------------------- ### Build Docker Image for Calcpad.WebApi Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.WebApi/README.md Builds a Docker image for the Calcpad.WebApi project. The resulting image is tagged as `calcpad/webapi:latest`. This script is crucial for containerized deployments. ```powershell ./docker-build.ps1 ``` -------------------------------- ### Uninstall Calcpad from Ubuntu Source: https://github.com/proektsoftbg/calcpad/blob/main/Setup/Linux/Readme.md Removes Calcpad from the Ubuntu system using apt-get. This command purges the package and its configuration files. ```bash sudo apt-get --purge remove calcpad ``` -------------------------------- ### Summation with Matrix and Vector in Calcpad Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Shows an example of the 'sum' function in Calcpad when used with matrices and vectors. Matrices are linearized into a common array for the summation operation. ```calcpad A = [0; 2| 4; 8] b = [5; 3; 1] sum(10; A; b; 11) ``` -------------------------------- ### GET /api/v1/calcpad-file/uids/{uniqueId}/uri Source: https://context7.com/proektsoftbg/calcpad/llms.txt Retrieves the URI for a previously uploaded file or resource using its unique ID. ```APIDOC ## GET /api/v1/calcpad-file/uids/{uniqueId}/uri ### Description Retrieves the access URI for a file or resource identified by its unique ID. ### Method GET ### Endpoint `/api/v1/calcpad-file/uids/{uniqueId}/uri` ### Parameters #### Path Parameters - **uniqueId** (string) - Required - The unique identifier of the file or resource. #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer YOUR_TOKEN`). ### Request Example ```bash curl -X GET "http://localhost:5098/api/v1/calcpad-file/uids/calc-001/uri" \ -H "Authorization: Bearer YOUR_TOKEN" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was successful. - **data** (string) - The URI of the requested file or resource. - **message** (string) - Any message associated with the response. ``` -------------------------------- ### Iterative and Numerical Methods Source: https://github.com/proektsoftbg/calcpad/blob/main/README.md API endpoints for root finding, optimization, integration, differentiation, and iterative calculations. ```APIDOC ## Iterative and Numerical Methods API ### Description This API provides functions for performing various numerical computations including root finding, optimization, integration, differentiation, and iterative processes. ### Endpoints * **POST /numerical/root** * **Description**: Finds the root(s) of a function `f(x)` within a given range `x = a:b`. * **Request Body**: `{"f": "function_string", "x_range": "a:b", "const": optional_scalar}` (Optional `const` for `f(x) = const`) * **Response**: `{"roots": [...]}` (List of roots) * **POST /numerical/find** * **Description**: Similar to root finding, but `x` is not required to be a precise solution. Finds an approximate solution for `f(x)` in the range `x = a:b`. * **Request Body**: `{"f": "function_string", "x_range": "a:b"}` * **Response**: `{"solution": scalar}` (Approximate solution) * **POST /numerical/sup** * **Description**: Finds the local maximum of a function `f(x)` within a given range `x = a:b`. * **Request Body**: `{"f": "function_string", "x_range": "a:b"}` * **Response**: `{"maximum": scalar}` (Local maximum value) * **POST /numerical/inf** * **Description**: Finds the local minimum of a function `f(x)` within a given range `x = a:b`. * **Request Body**: `{"f": "function_string", "x_range": "a:b"}` * **Response**: `{"minimum": scalar}` (Local minimum value) * **POST /numerical/area** * **Description**: Computes the adaptive Gauss-Lobatto numerical integration of a function `f(x)` over the range `x = a:b`. * **Request Body**: `{"f": "function_string", "x_range": "a:b"}` * **Response**: `{"integral": scalar}` (The computed integral value) * **POST /numerical/integral** * **Description**: Computes the Tanh-Sinh numerical integration of a function `f(x)` over the range `x = a:b`. * **Request Body**: `{"f": "function_string", "x_range": "a:b"}` * **Response**: `{"integral": scalar}` (The computed integral value) * **POST /numerical/slope** * **Description**: Computes the numerical differentiation (slope) of a function `f(x)` at a point `x = a`. * **Request Body**: `{"f": "function_string", "x_point": scalar}` * **Response**: `{"slope": scalar}` (The derivative at the point) * **POST /numerical/sum** * **Description**: Computes an iterative sum of a function `f(k)` from `k = a` to `b`. * **Request Body**: `{"f": "function_string", "k_range": "a:b"}` * **Response**: `{"result": scalar}` (The computed sum) * **POST /numerical/product** * **Description**: Computes an iterative product of a function `f(k)` from `k = a` to `b`. * **Request Body**: `{"f": "function_string", "k_range": "a:b"}` * **Response**: `{"result": scalar}` (The computed product) * **POST /numerical/repeat** * **Description**: Executes an expression block `f(k)` iteratively with a counter `k` from `a` to `b`. * **Request Body**: `{"f": "expression_block", "k_range": "a:b"}` * **Response**: `{"results": [...]}` (Results from each iteration) * **POST /numerical/while** * **Description**: Executes an expression block based on a condition. * **Request Body**: `{"condition": "boolean_expression", "expressions": "expression_block"}` * **Response**: `{"results": [...]}` (Results from executed expressions) * **POST /numerical/block** * **Description**: Executes a multiline expression block. * **Request Body**: `{"expressions": "multiline_expression_block"}` * **Response**: `{"results": [...]}` (Results from the block execution) ``` -------------------------------- ### Vector Structural Operations Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/help.html Provides functions for structural manipulation of vectors, including getting length, size, resizing, filling, joining, slicing, and extracting elements. ```calcpad len(⃗v) ``` ```calcpad size(⃗v) ``` ```calcpad resize(⃗v; n) ``` ```calcpad fill(⃗v; x) ``` ```calcpad join(M; ⃗v; x…) ``` ```calcpad slice(⃗v; i1; i2) ``` ```calcpad first(⃗v; n) ``` ```calcpad last(⃗v; n) ``` ```calcpad extract(⃗v; ⃗vi) ``` -------------------------------- ### Calcpad Quadratic Equation Solver Program Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html A sample program demonstrating how to solve a quadratic equation using Calcpad. It defines variables and uses them to calculate the roots of the equation. ```Calcpad a = 1 b = 2 c = 1 x1 = (-b + sqrt(b^2 - 4*a*c))/(2*a) x2 = (-b - sqrt(b^2 - 4*a*c))/(2*a) ``` -------------------------------- ### Search Matrix Element Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Finds the first occurrence of a value in a matrix starting from specified row and column indexes. Returns [0; 0] if the value is not found. ```calcpad msearch(M; value; start_row; start_col) ``` -------------------------------- ### Create Upper Triangular Matrix Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Initializes an n x n upper triangular matrix with all elements initially set to zero. Subsequent filling with values (e.g., using `mfill`) will populate the upper triangle. ```calcpad U = **utriang**(n) **mfill**(U; 1) ``` -------------------------------- ### HTML List Formatting in Calcpad Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Shows the HTML syntax for creating unordered (`
  • ...
`) and ordered (`
  1. ...
`) lists, insertable using the Calcpad formatting toolbar. Essential for presenting itemized information. ```HTML
  • ...
  • ...
  • ...
  1. ...
  2. ...
  3. ...
``` -------------------------------- ### Calcpad Search Function Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Searches for the first occurrence of a value 'x' in vector 'a' starting from index 'i'. Returns the index of the found element or 0 if not found or 'i' is out of bounds. ```Calcpad **search**(a; x; i) ``` -------------------------------- ### GUI Implementation with PyQt5 Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/Bulgarian/Html/parsing.bg.html This snippet showcases the implementation of a graphical user interface using the PyQt5 library in Python. It defines the main window, widgets, and their interactions for a calculator application. ```python class MainWindow(QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle("CalcPad") self.layout = QVBoxLayout() self.input_line = QLineEdit() self.input_line.setFixedHeight(40) self.input_line.setAlignment(Qt.AlignRight) self.input_line.setReadOnly(True) self.layout.addWidget(self.input_line) buttons = [ "7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", ".", "=", "+", ] self.buttons_grid = QGridLayout() for i, button_text in enumerate(buttons): button = QPushButton(button_text) button.setFixedSize(60, 60) button.clicked.connect(self.on_button_click) row = i // 4 col = i % 4 self.buttons_grid.addWidget(button, row, col) self.layout.addLayout(self.buttons_grid) container = QWidget() container.setLayout(self.layout) self.setCentralWidget(container) def on_button_click(self): button = self.sender() current_text = self.input_line.text() button_text = button.text() if button_text == "=": try: result = str(eval(current_text)) self.input_line.setText(result) except Exception as e: self.input_line.setText("Error") else: self.input_line.setText(current_text + button_text) ``` -------------------------------- ### Calcpad Get Index Order Descending Source: https://github.com/proektsoftbg/calcpad/blob/main/Translation/English/Html/readme.html Returns a vector of indices that represents the descending order of elements in the input vector. Similar to 'order', this can be used with 'extract' for reordering. ```Calcpad revorder([4; 0; 2; 3; -1; 1]) ' returns [1 4 3 6 2 5] ``` -------------------------------- ### GET /api/v1/calcpad-file/{calcId}/file-paths Source: https://context7.com/proektsoftbg/calcpad/llms.txt Retrieves a list of all file paths referenced within a specified Calcpad calculation file. ```APIDOC ## GET /api/v1/calcpad-file/{calcId}/file-paths ### Description Retrieves a list of all file paths referenced within a specified Calcpad calculation file. ### Method GET ### Endpoint `/api/v1/calcpad-file/{calcId}/file-paths` ### Parameters #### Path Parameters - **calcId** (string) - Required - The unique identifier of the Calcpad calculation file. #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "http://localhost:5098/api/v1/calcpad-file/calc-001/file-paths" \ -H "Authorization: Bearer YOUR_TOKEN" ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **data** (array of strings) - A list of file paths. - **message** (string) - Any additional messages related to the operation. #### Response Example ```json { "success": true, "data": ["./includes/material_data.txt", "./data/loads.csv", "./images/diagram.png"], "message": "" } ``` ``` -------------------------------- ### Calcpad CSS: Equation and Input Styles Source: https://github.com/proektsoftbg/calcpad/blob/main/Examples/Physics/Pendulums/Comparison of different methods for analysis of simple undamped pendulum.html Styles for rendering mathematical equations and input fields. It specifies fonts, colors, and spacing for equation elements like variables and subscripts, and provides styling for text inputs and dropdowns, including focus states. ```css .eq, input[type="text"], table.matrix { font-family: 'Georgia Pro', 'Century Schoolbook', 'Times New Roman', Times, serif; } .eq var { color: #06d; padding-right: 1pt; padding-left: 1pt; font-size: 11.5pt; } .eq i { color: #086; font-style: normal; font-size: 10pt; } .eq b { font-weight: 600; } .eq sub { font-family: 'Segoe UI', 'Gill Sans', 'Gill Sans MT', 'Trebuchet MS', sans-serif; font-size: 85%; vertical-align: -18%; } .eq sup { display: inline-block; margin-left: 1pt; margin-top: -3pt; } .eq small { font-family: 'Segoe UI', 'Gill Sans', 'Gill Sans MT', 'Trebuchet MS', sans-serif; font-size: 70%; } .eq small var { font-family: 'Georgia Pro', 'Century Schoolbook', 'Times New Roman', Times, serif; font-size: 8.5pt; } .eq small i { font-family: 'Georgia Pro', 'Century Schoolbook', 'Times New Roman', Times, serif; font-size: 6pt; } .eq u, input, select { background-color: LightYellow; } input[type="text"], select { font-size: 10pt; padding: 0.2em 0.4em; border: 0.5pt solid #CCC; border-radius: 0.35em; text-align: right; box-shadow: 0.06em 0.06em 0.5em #ddd; min-width: 3em; } input[type="text"]:focus { box-shadow: 0.1em 0.1em 1em #ccc; color: black; } ``` -------------------------------- ### Settings Class Properties Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Cli/Examples/Python/Readme.md The Settings class allows configuration of various aspects of the calculation process. It includes fields for MathSettings, PlotSettings, and units to be used in comments. ```python class Settings: Settings() Math : MathSettings Plot : PlotSettings Units : str ``` -------------------------------- ### Count Occurrences of Value in Vector in Calcpad Source: https://github.com/proektsoftbg/calcpad/blob/main/Calcpad.Wpf/doc/readme.html Counts the number of times a specific value 'x' appears in a vector 'a', starting from index 'i' (inclusive). If 'i' is out of bounds, it returns 0. ```Calcpad count([0; 1; 2; 1; 4; 1]; 1; 4) ```