C++ Armadillo :: eps














































C++ Armadillo :: eps



---------------------------------------------------------------------------------------------------------------
Description::
This is the basic C++ program of C++ armadillo library which shows how to get the distance of each element of matrix to the next largest representable floating point number. It can be carried out by the help of inbuilt function "eps" in armadillo library. It takes one parameter i.e input matrix name.
  • Obtain the positive distance of the absolute value of each element of X to the next largest representable floating point number
  • X can be a scalar (eg. double), vector or matrix
---------------------------------------------------------------------------------------------------------------
Program::

#include <iostream>
#include <armadillo>
using namespace std;
using namespace arma;

int main()
{
//initialize the random generator
//Create a 4 x 5 random matrix and printing it
mat A = randu<mat>(4,5); //random matrix of size 5 x 5 (generared by this syntax)
mat B = eps(A);
cout << "Matrix A::\n"<<endl;
cout<< A << endl;
cout << "Matrix B::\n"<<endl;
cout << B << endl; return 0; }
---------------------------------------------------------------------------------------------------------------
Commands to run program on terminal::
g++ filename.cpp -o objectname -O2 -larmadillo

$ ./objectname
---------------------------------------------------------------------------------------------------------------
Output::

Matrix A:: 0.7868 0.0193 0.5206 0.1400 0.4998 0.2505 0.4049 0.3447 0.5439 0.4194 0.7107 0.2513 0.2742 0.5219 0.7443 0.9467 0.0227 0.5610 0.8571 0.2492 Matrix B:: 1.1102e-16 3.4694e-18 1.1102e-16 2.7756e-17 5.5511e-17 5.5511e-17 5.5511e-17 5.5511e-17 1.1102e-16 5.5511e-17 1.1102e-16 5.5511e-17 5.5511e-17 1.1102e-16 1.1102e-16 1.1102e-16 3.4694e-18 1.1102e-16 1.1102e-16 2.7756e-17

More Articles of Shubham Loya:

Name Views Likes
C++ OpenCV cv::trace() 1444 1
C++ Armadillo :: Real and Imaginary part 1485 1
C++ OpenCV cv::perspectiveTransform() 4956 1
C++ Armadillo :: find_nonfinite 728 2
C++ Armadillo introduction and installation 551 1
C++ Armadillo :: Kron 1174 1
C++ Armadillo :: Accessing row and column and operations on it 1210 1
C++ Armadillo :: cond 436 2
C++ Armadillo :: pseudo-inverse 2642 1
C++ OpenCV cv::flip() 1663 1
C++ OpenCV cv::transpose() 6456 1
C++ Armadillo :: any 496 2
C++ Armadillo :: Max and Min of matrices 838 1
C++ OpenCV cv::pow() 2205 1
C++ Armadillo :: fliplr and flipud 935 2
C++ Armadillo :: Sort 1130 1
C++ Armadillo :: Determinant of Matrix 822 1
C++ Armadillo :: Indices of Unique elements of matrix 848 1
C++ Armadillo :: eps 453 3
C++ Armadillo :: Inverse 1313 1
C++ Armadillo :: Transpose of Matrix 1082 1
C++ Armadillo :: Basic Arithmetic Operations 433 1
C++ Armadillo :: Cross Product of vectors 1113 4
C++ OpenCV program to play a video 1093 1
C++ Armadillo :: Diagonal of Matrix 859 1
C++ Armadillo :: Absolute value of Matrix 1051 1
C++ Armadillo :: Conj 423 2
C++ Armadillo :: expmat 878 2
C++ OpenCV Input from Camera 1794 1
C++ OpenCV program to convert BGR image to grayscale image 5169 1
C++ Armadillo :: Intersect 703 2
C++ Armadillo :: Nonzeros 934 2
C++ Armadillo :: Dot Product of vectors 1523 2
C++ OpenCV:: Transforming BGR image to Grey scale image 545 2
C++ OpenCV to rotate an image 10530 1
C++ Armadillo :: Unique elements of matrix 759 1
C++ Armadillo :: Log Determinant 754 1
C++ Armadillo :: Sort_index 1370 2
C++ Armadillo :: Max Min 1436 1
C++ Armadillo :: Shift 822 1
C++ Armadillo :: Square root of Matrix 1605 1
C++ OpenCV cv::cvtColor() 2133 1

Comments