Universal Numbers Library C++ API
sw::universal -- header-only custom arithmetic types (posit, cfloat, lns, fixpnt, dd/qd, and more)
Loading...
Searching...
No Matches
evaluate_closure_of_number_systems.hpp File Reference
#include <iostream>
#include <string>
#include <string_view>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <universal/utility/generateClosurePlots.hpp>

Classes

struct  operationResults
struct  storeResults

Functions

void printResults (const storeResults &results)
 helper function for processASystem() formats and prints the results
std::string toPercentageString (float value, float totalOps)
 helper function for getDataFromBufferStream() coverts calculated from buildClosurePlot() to a percentage wrt the totalOps
int getDataFromBufferStream (storeResults &results, std::ostringstream &bufferStream, std::streambuf *oldBuf)
 helper function for processASystem() processes the data from buildClosurePlot() line by line
template<typename NumberType>
int processASystem (std::string sys_name)

Function Documentation

◆ getDataFromBufferStream()

int getDataFromBufferStream ( storeResults & results,
std::ostringstream & bufferStream,
std::streambuf * oldBuf )

helper function for processASystem() processes the data from buildClosurePlot() line by line

Parameters
resultsa struct that stores all of the statistics of the closure plot for a number system
bufferStreamthe stream that holds the data from stdout from buildClosurePlot()
oldBufthe old stdout stream buffer
Returns
int 0 if successful, 1 if errir wuth parsing data from the bufferStream

◆ printResults()

void printResults ( const storeResults & results)

helper function for processASystem() formats and prints the results

Parameters
resultsa struct that stores all of the statistics of the closure plot for a number system

◆ processASystem()

template<typename NumberType>
int processASystem ( std::string sys_name)
  • driver function, performs the following operations:
  1. calls buildClosurePlot to calculate closure plot values for a templatized number system
  2. puts the data to a buffer and converts processes it into structs
  3. prints the processed data to stdout
Template Parameters
NumberTypea generic number system compatible with this libray
Parameters
sys_namethe string represntation of the Number System
Returns
0 on success, 1 on failure

◆ toPercentageString()

std::string toPercentageString ( float value,
float totalOps )

helper function for getDataFromBufferStream() coverts calculated from buildClosurePlot() to a percentage wrt the totalOps

Parameters
valuethe current value to be converted to a percentage
totalOpsthe total amount of operations performed for the current arithmetic operation
Returns
string , the string representation of the percentage