📚
DLIP
  • Introduction
  • Prerequisite
  • Image Processing Basics
    • Notes
      • Thresholding
      • Spatial Filtering
      • Masking with Bitwise Operation
      • Model n Calibration
    • Tutorial
      • Tutorial: Install OpenCV C++
      • Tutorial: Create OpenCV Project
      • Tutorial: C++ basics
      • Tutorial: OpenCV Basics
      • Tutorial: Image Watch for Debugging
      • Tutorial: Spatial Filter
      • Tutorial: Thresholding and Morphology
      • Tutorial: Camera Calibration
      • Tutorial: Color Image Processing
      • Tutorial: Edge Line Circle Detection
      • Tutorial: Corner Detection and Optical Flow
      • Tutorial: OpenCV C++ Cheatsheet
      • Tutorial: Installation for Py OpenCV
      • Tutorial: OpenCv (Python) Basics
    • LAB
      • Lab Report Template
      • Lab Report Grading Criteria
      • LAB Report Instruction
      • LAB: Grayscale Image Segmentation
        • LAB: Grayscale Image Segmentation -Gear
        • LAB: Grayscale Image Segmentation - Bolt and Nut
      • LAB: Color Image Segmentation
        • LAB: Facial Temperature Measurement with IR images
        • LAB: Magic Cloak
      • LAB: Straight Lane Detection and Departure Warning
      • LAB: Dimension Measurement with 2D camera
      • LAB: Tension Detection of Rolling Metal Sheet
  • Deep Learning for Perception
    • Notes
      • Lane Detection with Deep Learning
      • Overview of Deep Learning
        • Object Detection
        • Deep Learning Basics: Introduction
        • Deep Learning State of the Art
        • CNN, Object Detection
      • Perceptron
      • Activation Function
      • Optimization
      • Convolution
      • CNN Overview
      • Evaluation Metric
      • LossFunction Regularization
      • Bias vs Variance
      • BottleNeck Unit
      • Object Detection
      • DL Techniques
        • Technical Strategy by A.Ng
    • Tutorial - PyTorch
      • Tutorial: Install PyTorch
      • Tutorial: Python Numpy
      • Tutorial: PyTorch Tutorial List
      • Tutorial: PyTorch Example Code
      • Tutorial: Tensorboard in Pytorch
      • Tutorial: YOLO in PyTorch
        • Tutorial: Yolov8 in PyTorch
        • Tutorial: Train Yolo v8 with custom dataset
          • Tutorial: Train Yolo v5 with custom dataset
        • Tutorial: Yolov5 in Pytorch (VS code)
        • Tutorial: Yolov3 in Keras
    • LAB
      • Assignment: CNN Classification
      • Assignment: Object Detection
      • LAB: CNN Object Detection 1
      • LAB: CNN Object Detection 2
      • LAB Grading Criteria
    • Tutorial- Keras
      • Train Dataset
      • Train custom dataset
      • Test model
      • LeNet-5 Tutorial
      • AlexNet Tutorial
      • VGG Tutorial
      • ResNet Tutorial
    • Resource
      • Online Lecture
      • Programming tutorial
      • Books
      • Hardware
      • Dataset
      • Useful sites
  • Must Read Papers
    • AlexNet
    • VGG
    • ResNet
    • R-CNN, Fast-RCNN, Faster-RCNN
    • YOLOv1-3
    • Inception
    • MobileNet
    • SSD
    • ShuffleNet
    • Recent Methods
  • DLIP Project
    • Report Template
    • DLIP 2021 Projects
      • Digital Door Lock Control with Face Recognition
      • People Counting with YOLOv4 and DeepSORT
      • Eye Blinking Detection Alarm
      • Helmet-Detection Using YOLO-V5
      • Mask Detection using YOLOv5
      • Parking Space Management
      • Vehicle, Pedestrian Detection with IR Image
      • Drum Playing Detection
      • Turtle neck measurement program using OpenPose
    • DLIP 2022 Projects
      • BakeryCashier
      • Virtual Mouse
      • Sudoku Program with Hand gesture
      • Exercise Posture Assistance System
      • People Counting Embedded System
      • Turtle neck measurement program using OpenPose
    • DLIP Past Projects
  • Installation Guide
    • Installation Guide for Pytorch
      • Installation Guide 2021
    • Anaconda
    • CUDA cuDNN
      • CUDA 10.2
    • OpenCV
      • OpenCV Install and Setup
        • OpenCV 3.4.13 with VS2019
        • OpenCV3.4.7 VS2017
        • MacOS OpenCV C++ in XCode
      • Python OpenCV
      • MATLAB-OpenCV
    • Framework
      • Keras
      • TensorFlow
        • Cheat Sheet
        • Tutorial
      • PyTorch
    • IDE
      • Visual Studio Community
      • Google Codelab
      • Visual Studio Code
        • Python with VS Code
        • Notebook with VS Code
        • C++ with VS Code
      • Jupyter Notebook
        • Install
        • How to use
    • Ubuntu
      • Ubuntu 18.04 Installation
      • Ubuntu Installation using Docker in Win10
      • Ubuntu Troubleshooting
    • ROS
  • Programming
    • Python_Numpy
      • Python Tutorial - Tips
      • Python Tutorial - For Loop
      • Python Tutorial - List Tuple, Dic, Set
    • Markdown
      • Example: API documentation
    • Github
      • Create account
      • Tutorial: Github basic
      • Tutorial: Github Desktop
    • Keras
      • Tutorial Keras
      • Cheat Sheet
    • PyTorch
      • Cheat Sheet
      • Autograd in PyTorch
      • Simple ConvNet
      • MNIST using LeNet
      • Train ConvNet using CIFAR10
  • Resources
    • Useful Resources
    • Github
Powered by GitBook
On this page
  • Numerical Programming API
  • Non-Linear Solver
  • newtonRaphson()
  • Linear Solver
  • gaussElim()
  • inv()
  • Numerical Differentiation
  • gradient1D()
  • Integration
  • integral()
  • ODE-IVP
  • odeEU()
  • Class or Header name
  • Function Name

Was this helpful?

  1. Programming
  2. Markdown

Example: API documentation

Numerical Method example

Numerical Programming API

#include "myNM.h"

Non-Linear Solver

newtonRaphson()

Solves the non-linear problem using Newton-Raphson method

double newtonRaphson(double x0, double tol);

Parameters

  • x0: initial value.

  • tol: tolerance error

Example code

double tol = 0.00001;
double x0 = 3;
double NR_result;
​
NR_result = newtonRaphson(x0, tol);

Linear Solver

gaussElim()

solves for vector x from Ax=b, a linear system problem Using Gauss Elimination

void gaussElim(Matrix _A, Matrix _B, Matrix* _U, Matrix* _B_out);

Parameters

  • A: Matrix A in structure Matrix form. Should be (nxn) square.

  • B: vector b in structure Matrix form. Should be (nx1)

  • U: Matrix U in structure Matrix form. Should be (nxn) square.

  • B_out: vector B_out in structure Matrix form. Should be (nx1)

Example code

Matrix matA = txt2Mat(path, "prob1_matA");
Matrix vecb = txt2Mat(path, "prob1_vecb");
Matrix matU = zeros(matA.rows, matA.cols);
Matrix vecd = zeros(vecb.rows, vecb.cols);
​
gaussElim(matA, vecb, matU, vecd);

inv()

Find the inverse Matrix.

void inv(Matrix _A, Matrix _Ainv);

Parameters

  • A: Matrix A in structure Matrix form. Should be (nxn) square.

  • Ainv: Matrix Ainv in structure Matrix form. Should be (nxn) square.

Example code

Matrix matA = txt2Mat(path, "prob1_matA");
Matrix matAinv = zeros(matA.rows, matA.cols);
​
inv(matA, matAinv);

Numerical Differentiation

gradient1D()

Solve for numerical gradient (dy/dt) from a 1D-array form.

void gradient1D(double x[], double y[], double dydx[], int m);

Parameters

  • x[]: input data vector x in 1D-array .

  • y[]: input data vector y in 1D-array.

  • dydx[]: output vector dydx in 1D-array.

  • m: length x and y.

Example code

double x[21];
    for (int i = 0; i < 21; i++) {
        x[i] = 0.2 * i;
    }
double y[] = { -5.87, -4.23, -2.55, -0.89, 0.67, 2.09, 3.31, 4.31, 5.06, 5.55, 5.78, 5.77, 5.52, 5.08, 4.46, 3.72, 2.88, 2.00, 1.10, 0.23, -0.59 };
double dydx[21];
​
gradient1D(x, y, dydx, 21);

Integration

integral()

Integral using Simpson 1/3 Method.

double integral(double func(const double _x), double a, double b, int n);

Parameters

  • func: Function func is defined.

  • a is starting point of x.

  • b is ending point of x.

  • n is the length between a and b

Example code

double I_simpson13 = integral(myFunc, -1, 1, 12);

double myFunc(const double _x) {
	return sqrt(1 - (_x * _x));
}

ODE-IVP

odeEU()

Solve the 1st-order ODE using Euler's Explicit Method.

void odeEU(double func(const double x, const double y), double y[], double t0, double tf, double h, double y0);

Parameters

  • func: Function func is defined.

  • y[]: Solution of ODE in structure 1D-array form.

  • t0 is starting point.

  • tf is ending point.

  • h is length of step.

  • y0 is initial value of y[].

Example code

double a = 0;
double b = 0.1;
double h = 0.001;
double y_EU[200] = { 0 };
double v0 = 0;

odeEU(odeFunc_rc, y_EU, a, b, h, v0);

double odeFunc_rc(const double t, const double v) {
	double tau = 1;
	double T = 1 / tau;
	double f = 10;
	double Vm = 1;
	double omega = 2 * PI * f;
	return  -T * v + T * Vm * cos(omega * t);
}

-------------------------------------------------------------------------------------------------------

Class or Header name

Function Name

Parameters

  • p1

  • p2

Example code

PreviousMarkdownNextGithub

Last updated 3 years ago

Was this helpful?