Lab06_Libraries_and_..

advertisement
Libraries and STL Timing
Laboratory 6
revision 1
Identity Software
CS 340 Group 4
February 12, 2016
Approval
We hereby approve the contents of this report, and certify that we each contributed
fairly to its completion.
Jean Ablutz
James Evans
Erin Geaney
Dong Kim
Konrad Lorincz
i
Contents
1. STL RELATED SITES ........................................................................................................................................... 1
2. NON-STL C++ CLASS LIBRARIES .................................................................................................................... 1
3. FORTRAN MATHEMATICAL LIBRARIES ..................................................................................................... 2
4. STL TIMING ........................................................................................................................................................... 3
4.1 RESULTS ..............................................................................................................................................................3
4.2 CODE ...................................................................................................................................................................4
ii
Libraries and STL Timing
Laboratory 6
1. STL Related Sites

Several simple example programs that use the STL. It includes: demonstrating STL
vectors and vector iterators, anagram-checking , and demonstrating sorting and
searching with user-defined records
o http://www.cs.rpi.edu/~musser/stl-examples.html

A comprehensive document describing in detail STL and its functionality
o http://www.cs.rpi.edu/~musser/doc.ps

Standard Template Library Programmer's Guide – A very good reference source on
the STL. It contains a detailed a description of all of the STL’s classes and functions
and provides good examples for each one
o http://www.sgi.com/Technology/STL/

Dinkum C++ Library Reference – another good reference on the STL. Contains
HTML links to all the STL classes and functions
o http://www.dinkumware.com/htm_cpl/index.html#STL

Mumit's STL Newbie Guide – Another excellent reference guide to the STL library
o http://www.xraylith.wisc.edu/~khan/software/stl/STL.newbie.html#iterators
2. Non-STL C++ Class Libraries

C++ Library for Unicode - general purpose source code library for working with text
in Unicode.
o http://unicode.basistech.com/

Statistics libraries - matrix manipulation and random number generation.
o http://webnz.com/robert/

Communications Networks Class Library (CNCL) - simulation library including
random number generation, statistics, and event driven simulation.
o http://www.comnets.rwth-aachen.de/doc/cncl.html

YACL (Yet Another Class Library) is a C++ class library that offers high-level
abstractions for common programming problems. Its class protocols are designed to:
02/12/16
1
Libraries and STL Timing
Laboratory 6
o Be application-centered, i.e., represent concepts close to those needed by the
programmer, thus making programming using them significantly easier than
otherwise
o Make good use of C++ facilities (operator overloading and templates in
particular) to minimize the amount of code a programmer must write
o Provide adequate hooks for easy extensibility
o http://www.cs.sc.edu/~sridhar/yacl/

Tools.h++ - class library contains over 120 classes, including dates, times and strings,
sets, bags, B-Trees, sorted collections, linked lists, queues, stacks, and more.
o http://www.roguewave.com/products/tools/tools.html

MetaKit - class library to manage persistent storage and transport of structured data
o http://www.equi4.com/metakit/
3. Fortran Mathematical Libraries

EISACK - a collection of Fortran subroutines that compute the eigenvalues and
eigenvectors of nine classes of matrices: complex general, complex Hermitian, real
general, real symmetric, real symmetric banded, real symmetric tridiagonal, special
real tridiagonal, generalized real, and generalized real symmetric matice
o http://www.netlib.org/eispack/

BLAS (Basic Linear Algebra Subprograms) - high quality "building block" routines
for performing basic vector and matrix operations. Level 1 BLAS do vector-vector
operations, Level 2 BLAS do matrix-vector operations, and Level 3 BLAS do matrixmatrix operations
o http://www.netlib.org/blas/faq.html#1.1

MINPACK - library for solving nonlinear systems of equations and nonlinear least
squares problems.
o http://www.scd.ucar.edu/softlib/MINPACK.html

NCAR’s Mathematical and Statistical Libraries - large and valuable collection of
mathematical and statistical software. It includes Fast Fourier Transforms, Separable
Elliptic PDEs, Legendre Polynomials, Spherical Harmonics, General Mathematics,
02/12/16
2
Libraries and STL Timing
Laboratory 6
Linear Equation Solvers, Nonlinear Equation Solvers, and Ordinary Differential
Equations
o http://www.scd.ucar.edu/softlib/mathlib.html
4. STL Timing
4.1 Results
*** Timing Vector Insertion ***
This program calculates the time spent to find a randomly generated
integer from the vector of size n.
n = 10
Avg. Total time:
0
Avg. Time per element:
0
n = 1000
Avg. Total time:
0
Avg. Time per element:
0
n = 10000
Avg. Total time:
0
Avg. Time per element:
0
n = 1000000
Avg. Total time:
23.6364
Avg. Time per element:
2.36364e-05
The above results show the average time spent on finding an element. The program tries
to find 10 randomized elements for each vector of different sizes. The average total time
is the total elapsed time divided the number of elements that was searched. The average
time per element is the average total time divided by the size of the vector. The results
show that for vectors of size under 10000, the average total time and average time per
elements are too small to be differentiated from zero by a double precision floating type
02/12/16
3
Libraries and STL Timing
Laboratory 6
value. This proves that find() function for vectors from the STL library works very
efficiently in terms of time performance. For the element to be looked up, the
randomize() function was used to test on various ranges data.
4.2 Code
//
//
//
//
//
//
//
****************************************************************
Author: Konrad Lorincz (Group 4)
Date:
March 4, 2000
Description: This program calculates the time spent to find a
randomly generated integer from the vector of size n.
****************************************************************
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include
#include
#include
#include
<iostream>
<string>
<vector>
<algorithm>
using namespace std;
void FindInVector(int n)
{
//Vect.resize(n);
vector<int> Vect;
for (int i = 0; i < n; ++i)
Vect.push_back(i);
double elapsedTime = 0.0;
int j = 0.0;
for (j = 1; j <= 10; ++j)
{
randomize();
int Nbr = random(n);
// random number 0-n
clock_t startTime = clock();
find(Vect.begin(), Vect.end(), Nbr);
clock_t endTime = clock();
elapsedTime = elapsedTime + double(endTime - startTime);
}
cout << "\nn = " << n << endl;
02/12/16
4
Libraries and STL Timing
Laboratory 6
cout << "Avg. Total time: \t" << elapsedTime/j << endl;
cout << "Avg. Time per element: \t" << elapsedTime/n/j << endl;
}
int main()
{
cout << "\t\t *** Timing Vector Insertion ***\n" << endl;
cout << "This program calculates the time spent to find a randomly "
<< "generated integer from the vector of size n." << endl;
FindInVector(10);
FindInVector(1000);
FindInVector(10000);
FindInVector(1000000);
char end;
cin >> end;
return 0;
}
02/12/16
5
Download