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() 1314 1
C++ Armadillo :: Real and Imaginary part 1313 1
C++ OpenCV cv::perspectiveTransform() 4512 1
C++ Armadillo :: find_nonfinite 627 2
C++ Armadillo introduction and installation 526 1
C++ Armadillo :: Kron 1059 1
C++ Armadillo :: Accessing row and column and operations on it 912 1
C++ Armadillo :: cond 402 2
C++ Armadillo :: pseudo-inverse 2362 1
C++ OpenCV cv::flip() 1458 1
C++ OpenCV cv::transpose() 5802 1
C++ Armadillo :: any 456 2
C++ Armadillo :: Max and Min of matrices 729 1
C++ OpenCV cv::pow() 1985 1
C++ Armadillo :: fliplr and flipud 854 2
C++ Armadillo :: Sort 997 1
C++ Armadillo :: Determinant of Matrix 753 1
C++ Armadillo :: Indices of Unique elements of matrix 764 1
C++ Armadillo :: eps 408 3
C++ Armadillo :: Inverse 1094 1
C++ Armadillo :: Transpose of Matrix 942 1
C++ Armadillo :: Basic Arithmetic Operations 411 1
C++ Armadillo :: Cross Product of vectors 969 4
C++ OpenCV program to play a video 992 1
C++ Armadillo :: Diagonal of Matrix 767 1
C++ Armadillo :: Absolute value of Matrix 966 1
C++ Armadillo :: Conj 376 2
C++ Armadillo :: expmat 800 2
C++ OpenCV Input from Camera 1597 1
C++ OpenCV program to convert BGR image to grayscale image 4647 1
C++ Armadillo :: Intersect 646 2
C++ Armadillo :: Nonzeros 824 2
C++ Armadillo :: Dot Product of vectors 1414 2
C++ OpenCV:: Transforming BGR image to Grey scale image 507 2
C++ OpenCV to rotate an image 9573 1
C++ Armadillo :: Unique elements of matrix 687 1
C++ Armadillo :: Log Determinant 700 1
C++ Armadillo :: Sort_index 1255 2
C++ Armadillo :: Max Min 1299 1
C++ Armadillo :: Shift 702 1
C++ Armadillo :: Square root of Matrix 1424 1
C++ OpenCV cv::cvtColor() 1917 1

Comments