void SparseMatrixF :: ReadDiagonal(double *dv) { for ( unsigned long j = 0; j < neq; j++ ) { for ( unsigned long ad = Adr(j); ad < Adr(j + 1); ad++ ) { unsigned long i = Ci(ad); if ( i == j ) { dv [ j ] = a [ ad ]; } } } }
void SparseMatrixF :: GetA12block(double *pA12, long c) { for ( unsigned long j = neq - c; j < neq; j++ ) { for ( unsigned long ad = Adr(j); ad < Adr(j + 1); ad++ ) { unsigned long i = Ci(ad); if ( i < ( neq - c ) ) { pA12 [ i * c + ( j - ( neq - c ) ) ] = a [ ad ]; } } } }
void SparseMatrixF :: MulSymMatrixByVector(double *b, double *c) { for ( unsigned long j = 0; j < neq; j++ ) { for ( unsigned long ad = Adr(j); ad < Adr(j + 1); ad++ ) { double A = a [ ad ]; unsigned long i = Ci(ad); c [ i ] += A * b [ j ]; if ( i != j ) { c [ j ] += A * b [ i ]; } } } }
void SparseMatrixF :: mxv_scr(double *b, double *c) { unsigned long i, j, ii, lj, uj; double s, d; for ( i = 0; i < neq; i++ ) { lj = Adr(i); uj = Adr(i + 1); s = 0.0; d = b [ i ]; for ( j = lj; j < uj; j++ ) { ii = Ci(j); s += a [ j ] * b [ ii ]; c [ ii ] += a [ j ] * d; } c [ i ] = s; } }
bool connection::do_parse_handshake() { // DLOG(INFO) << "Parsing handshake"; const link_handshake<Adr>* handshake = buffer_cast<const link_handshake<Adr>*>(link_.received_buffer()); if (std::memcmp(handshake->sig, handshake_signature, sizeof(handshake->sig)) || handshake->protocol != link_.protocol_version) return false; routing_type_ = std::min(routing_type_, connection::routing_type(handshake->type & 0x03)); incoming_port_ = u16(handshake->incoming_port); typename Adr::bytes_type ip_bytes; std::memcpy(ip_bytes.data(), handshake->remote_ip, ip_bytes.size()); reported_peer_address_ = Adr(ip_bytes); supported_protocols_.resize(handshake->supported_protocol_count); link_.consume_receive_buffer(sizeof(link_handshake<Adr>) - sizeof(handshake->supported_protocols)); return true; }
void SparseMatrixF :: MulNonsymMatrixByVector(double *b, double *c) { switch ( m_eSparseOrientation ) { case eCompressedColumns: { for ( unsigned long j = 0; j < neq; j++ ) { for ( unsigned long ad = Adr(j); ad < Adr(j + 1); ad++ ) { double A = a [ ad ]; unsigned long i = Ci(ad); c [ i ] += A * b [ j ]; } } } break; case eCompressedRows: { for ( unsigned long j = 0; j < neq; j++ ) { for ( unsigned long ad = Adr(j); ad < Adr(j + 1); ad++ ) { double A = a [ ad ]; unsigned long i = Ci(ad); c [ j ] += A * b [ i ]; } } } break; default: fprintf(stderr, "SparseMatrixF::MulNonsymMatrixByVector: unsupported m_eSparseOrientation value\n"); abort(); } }