yang.cc File Reference

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include "yang.h"

Go to the source code of this file.

Functions

void error (const char *v)
Vtr operator+ (const Vtr &v)
Vtr operator- (const Vtr &v)
Vtr operator+ (const Vtr &v1, const Vtr &v2)
Vtr operator- (const Vtr &v1, const Vtr &v2)
std::ostream & operator<< (std::ostream &s, const Vtr &v)
Vtr operator* (const double scalar, const Vtr &v)
Vtr operator* (const Vtr &v1, const Vtr &v2)
Vtr operator/ (const Vtr &v, const double scalar)
double dot (const Vtr &v1, const Vtr &v2)
Mtx operator- (const Mtx &mat)
Vtr operator* (const Vtr &v, const Mtx &mat)
Mtx operator- (const Mtx &m1, const Mtx &m2)
std::ostream & operator<< (std::ostream &s, const Mtx &mat)

Function Documentation

double dot ( const Vtr v1,
const Vtr v2 
)

Definition at line 127 of file yang.cc.

Referenced by Mtx::QRdecomp(), Mtx::QRdecomp_slow(), and Simplex::size().

00127                                            {
00128   int sz = v1.lenth;
00129   if (sz != v2.lenth ) error("bad vtor sizes");
00130   double tm = v1[0]*v2[0];
00131   for (int i = 1; i < sz; i++) tm += v1[i]*v2[i];
00132   return tm;
00133 }

void error ( const char *  v  ) 

Definition at line 11 of file yang.cc.

Referenced by XmlRpc::XmlRpcServer::acceptConnection(), SimpleUDP::bind(), XmlRpc::XmlRpcServer::bindAndListen(), SimpleUDP::connect(), Nps::coordsReqRpcResponse(), SingleHostUnderlayConfigurator::createNode(), KBRTestApp::deliver(), XmlRpc::XmlRpcClient::doConnect(), dot(), oversim::Koorde::findDeBruijnHop(), oversim::Koorde::findNode(), BrooseBucket::get(), Mtx::getcol(), P2pnsCache::getDataAtPos(), BrooseBucket::getDist(), SimpleUDP::getEphemeralPort(), oversim::ChordSuccessorList::getSuccessor(), Broose::handleBucketRequestRpc(), Broose::handleBucketResponseRpc(), XmlRpcInterface::handleCommonAPIPacket(), XmlRpc::XmlRpcClient::handleEvent(), P2pnsCache::handleMessage(), GlobalStatistics::handleMessage(), GlobalCoordinator::handleMessage(), DHTDataStorage::handleMessage(), oversim::ChordSuccessorList::handleMessage(), oversim::ChordFingerTable::handleMessage(), BrooseBucket::handleMessage(), AccessNet::handleMessage(), GiaTokenFactory::handleMessages(), GiaNeighbors::handleMessages(), GiaKeyListModule::handleMessages(), oversim::Koorde::handleRpcDeBruijnRequest(), SimpleGameClient::handleTimerEvent(), oversim::Chord::handleTimerEvent(), Broose::handleTimerEvent(), oversim::Chord::handleUDPMessage(), CBRDHT::handleUpperMessage(), GlobalNodeList::initialize(), InetUnderlayConfigurator::initializeUnderlay(), Kademlia::isSiblingFor(), oversim::Chord::isSiblingFor(), Broose::isSiblingFor(), BasePastry::isSiblingFor(), SingleHostUnderlayConfigurator::migrateNode(), Mtx::operator*(), operator*(), operator+(), Mtx::operator+=(), Vtr::operator+=(), operator-(), Mtx::operator-=(), Vtr::operator-=(), operator/(), Mtx::operator=(), Vtr::operator=(), XmlRpc::XmlRpcClient::parseResponse(), SingleHostUnderlayConfigurator::preKillNode(), SimpleUDP::processCommandFromApp(), SimpleUDP::processUDPPacket(), SimpleUDP::processUndeliverablePacket(), XmlRpc::XmlRpcServerConnection::readHeader(), XmlRpcInterface::readHeader(), XmlRpc::XmlRpcClient::readHeader(), XmlRpc::XmlRpcServerConnection::readRequest(), XmlRpcInterface::readRequest(), XmlRpc::XmlRpcClient::readResponse(), MessageObserver::receivedMessage(), GlobalNodeList::refreshEntry(), GlobalNodeList::registerPeer(), MessageObserver::sentMessage(), Mtx::setcol(), SimpleUDP::unbind(), XmlRpc::XmlRpcDispatch::waitForAndProcessEvents(), XmlRpc::XmlRpcClient::writeRequest(), XmlRpc::XmlRpcServerConnection::writeResponse(), and XmlRpcInterface::writeResponse().

00011                           {
00012   std::cout << v << "\n";
00013   exit(1);
00014 }

Vtr operator* ( const Vtr v,
const Mtx mat 
)

Definition at line 214 of file yang.cc.

00215 {
00216         if (v.lenth != mat.nrows)
00217                 error("op*(Vtr, Mtx): Error: Mat. and vec. size do no match.");
00218         Vtr res(mat.ncols, 0.0);
00219         for (int i=0; i<mat.ncols; i++)
00220                 for (int j=0; j<v.lenth; j++)
00221                         res[i] = v.ets[j] * mat.ets[j][i];
00222         return res;
00223 }

Vtr operator* ( const Vtr v1,
const Vtr v2 
)

Definition at line 113 of file yang.cc.

00113                                               {
00114   int sz = v1.lenth;
00115   if (sz != v2.lenth ) error("bad vtor sizes");
00116   Vtr tm(sz);
00117   for (int i = 0; i < sz; i++)
00118       tm[i] = v1[i]*v2[i];
00119   return tm;
00120 }

Vtr operator* ( const double  scalar,
const Vtr v 
)

Definition at line 107 of file yang.cc.

00107                                                   {
00108   Vtr tm(v.lenth);
00109   for (int i = 0; i < v.lenth; i++) tm[i] = scalar*v[i];
00110   return tm;
00111 }

Vtr operator+ ( const Vtr v1,
const Vtr v2 
)

Definition at line 65 of file yang.cc.

00065                                              {          // v=v1+v2
00066   if (v1.lenth != v2.lenth ) error("Vtr::op+: Error Bad vtor sizes");
00067   Vtr sum = v1; // It would cause problem without copy constructor
00068   sum += v2;
00069   return sum;
00070 }

Vtr operator+ ( const Vtr v  ) 

Definition at line 57 of file yang.cc.

00057                              {  // usage: v1 = + v2;
00058   return v;
00059 }

Mtx operator- ( const Mtx m1,
const Mtx m2 
)

Definition at line 226 of file yang.cc.

00226                                              {  // matrix subtract
00227  if(m1.nrows !=m2.nrows || m1.ncols !=m2.ncols)
00228    error("bad matrix sizes");
00229  Mtx sum = m1;
00230  sum -= m2;
00231  return sum;
00232 }

Mtx operator- ( const Mtx mat  ) 

Definition at line 195 of file yang.cc.

00195                                 {               // usage: mat1 = - mat2;
00196   return Mtx(mat.nrows,mat.ncols) - mat;
00197 }

Vtr operator- ( const Vtr v1,
const Vtr v2 
)

Definition at line 72 of file yang.cc.

00072                                             { // v=v1-v2
00073 //  if (v1.lenth != v2.lenth ) error("bad vtor sizes");
00074   Vtr sum = v1; // It would cause problem without copy constructor
00075   sum -= v2;
00076   return sum;
00077 }

Vtr operator- ( const Vtr v  ) 

Definition at line 61 of file yang.cc.

00061                             {    // usage: v1 = - v2;
00062   return Vtr(v.lenth) - v;
00063 }

Vtr operator/ ( const Vtr v,
const double  scalar 
)

Definition at line 122 of file yang.cc.

00122                                                   {
00123   if (scalar == 0) error("division by zero in vector-scalar division");
00124   return (1.0/scalar)*v;
00125 }

std::ostream& operator<< ( std::ostream &  s,
const Mtx mat 
)

Definition at line 272 of file yang.cc.

00273 {
00274         for (int i = 0; i < mat.rows(); i++) {
00275                 s << "| ";
00276                 for(int j = 0; j < mat.cols(); j++) {
00277                         s.setf(std::ios_base::fixed, std::ios_base::floatfield);
00278                         s.precision(4);
00279                         s.width(8);
00280                         s << mat.ets[i][j];
00281                 }
00282                 s << " |" << std::endl;
00283         }
00284         return s;
00285 }

std::ostream& operator<< ( std::ostream &  s,
const Vtr v 
)

Definition at line 79 of file yang.cc.

00079                                                       {
00080   for (int i =0; i < v.lenth; i++ ) {
00081     s << v[i] << "  ";
00082     if (i%10 == 9) s << "\n";
00083   }
00084   return s;
00085 }

Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3