MtxObj Class Reference

Adapter class for fitting mtx to the nub::object interface. More...

#include <pkgs/mtx/mtxobj.h>

Inheritance diagram for MtxObj:

Inheritance graph
[legend]
Collaboration diagram for MtxObj:

Collaboration graph
[legend]

List of all members.

Public Types

typedef mtx_base< data_holderBase
typedef index_iterator_base
< mtx_base, double > 
iterator
typedef index_iterator_base
< const mtx_base, const double > 
const_iterator
typedef colmaj_iterator_base
< double > 
colmaj_iter
typedef colmaj_iterator_base
< const double > 
const_colmaj_iter
typedef rowmaj_iterator_base
< double > 
rowmaj_iter
typedef rowmaj_iterator_base
< const double > 
const_rowmaj_iter
enum  init_policy { ZEROS, NO_INIT }
enum  storage_policy { COPY, BORROW, REFER }

Public Member Functions

template<class T1>
 MtxObj (T1 t1)
template<class T1, class T2>
 MtxObj (T1 t1, T2 t2)
template<class T1, class T2, class T3>
 MtxObj (T1 t1, T2 t2, T3 t3)
template<class T1, class T2, class T3, class T4>
 MtxObj (T1 t1, T2 t2, T3 t3, T4 t4)
virtual rutz::fstring obj_typename () const
 Returns the (apparent) typename of the full object.
void resize (int mrows_new, int ncols_new)
mtx contig () const
data_holderget_data_holder ()
void print (std::ostream &s, const char *mtx_name="") const
 Print the mtx to the given ostream, including the matrix name if non-empty.
void print_stdout () const
 Print the mtx to stdout.
void print_stdout_named (const char *mtx_name) const
 Print the mtx to stdout along with a name for the mtx.
rutz::fstring as_string () const
 Convert the mtx to a string, by printing it to a string stream.
void scan (std::istream &s)
 Read the mtx from the given istream.
void scan_string (const char *s)
 Read the mtx from the given string.
double & at (int row, int col)
const double & at (int row, int col) const
double & at (int elem)
const double & at (int elem) const
bool same_size (const mtx &x) const
sub_mtx_ref sub (const row_index_range &rng)
sub_mtx_ref sub (const col_index_range &rng)
sub_mtx_ref sub (const row_index_range &rr, const col_index_range &cc)
mtx sub (const row_index_range &rng) const
mtx sub (const col_index_range &rng) const
mtx sub (const row_index_range &rr, const col_index_range &cc) const
mtx operator() (const row_index_range &rng) const
mtx operator() (const col_index_range &rng) const
mtx operator() (const row_index_range &rr, const col_index_range &cc) const
mtx as_shape (const mtx_shape &s) const
mtx as_shape (int mr, int nc) const
slice row (int r) const
mtx_iter row_iter (int r)
mtx_const_iter row_iter (int r) const
mtx as_row () const
void reorder_rows (const mtx &index)
slice column (int c) const
mtx_iter column_iter (int c)
mtx_const_iter column_iter (int c) const
mtx as_column () const
void reorder_columns (const mtx &index)
void swap_columns (int c1, int c2)
mtx mean_row () const
mtx mean_column () const
const_iterator find_min () const
const_iterator find_max () const
double min () const
double max () const
double sum () const
double mean () const
mtxoperator+= (double x)
mtxoperator+= (const mtx &other)
mtxoperator-= (double x)
mtxoperator-= (const mtx &other)
mtxoperator*= (double fac)
mtxoperator/= (double div)
bool operator== (const mtx &other) const
bool operator!= (const mtx &other) const
void assign_MMmul (const mtx &m1, const mtx &m2)
void make_unique ()
void swap (mtx_specs &other)
int offset_from_storage (int elem) const
const mtx_shapeshape () const
const mtx_specsspecs () const
double & at_nc (int i)
void apply (F func)
iterator begin_nc ()
iterator end_nc ()
const_iterator begin () const
const_iterator end () const
colmaj_iter colmaj_begin_nc ()
colmaj_iter colmaj_end_nc ()
const_colmaj_iter colmaj_begin () const
const_colmaj_iter colmaj_end () const
rowmaj_iter rowmaj_begin_nc ()
rowmaj_iter rowmaj_end_nc ()
const_rowmaj_iter rowmaj_begin () const
const_rowmaj_iter rowmaj_end () const
void clear (double x=0.0)
void select_rows (const row_index_range &rng)
void select_cols (const col_index_range &rng)
mtx_specs sub_rows (const row_index_range &rng) const
mtx_specs sub_cols (const col_index_range &rng) const
ptrdiff_t offset () const
int max_dim () const
int nelems () const
int mrows () const
int rowstride () const
int ncols () const
int colstride () const
unsigned int rowgap () const
int offset_from_start (int row, int col) const
int offset_from_start (int elem) const
nub::uid id () const throw ()
rutz::fstring real_typename () const
 Returns the typename of the full object.
rutz::fstring unique_name () const
 Returns a short string describing the object by its typename and id.
void * operator new (size_t bytes)
void operator delete (void *space, size_t bytes)
void mark_as_volatile () throw ()
 Mark this object as a volatile (unshareable) object.
void incr_ref_count () const throw ()
 Increment the object's reference count.
void decr_ref_count () const throw ()
 Decrement the object's reference count.
void decr_ref_count_no_delete () const throw ()
 Decrement the object's reference count, but don't delete it.
bool is_shared () const throw ()
 Returns true if no external client has sole ownership of the object.
bool is_unshared () const throw ()
 Returns true if there is a sole external owner of the object.
bool is_not_shareable () const throw ()
ref_counts * get_counts () const throw ()
 Returns the object's reference count manager.
int dbg_ref_count () const throw ()
 FOR TEST/DEBUG ONLY! Returns the object's (strong) reference count.
int dbg_weak_ref_count () const throw ()
 FOR TEST/DEBUG ONLY! Returns the object's weak reference count.

Static Public Member Functions

static MtxObjmake ()
static const mtxempty_mtx ()
static mtx colmaj_copy_of (const double *data, int mrows, int ncols)
 Set up a mtx with a storage policy of COPY.
static mtx colmaj_borrow_from (double *data, int mrows, int ncols)
 Set up a mtx with a storage_policy of BORROW.
static mtx colmaj_refer_to (double *data, int mrows, int ncols)
 Set up a mtx with a storage_policy of REFER.
static mtx zeros (const mtx_shape &s)
static mtx zeros (int mrows, int ncols)
static mtx uninitialized (const mtx_shape &s)
static mtx uninitialized (int mrows, int ncols)
static mtx from_stream (std::istream &s)
static mtx from_string (const char *s)
static void VMmul_assign (const slice &vec, const mtx &mtx, slice &result)

Protected Member Functions

void swap (mtx_base &other)
ptrdiff_t offset_from_storage (int r, int c) const
double * address_nc (int row, int col)
const double * address (int row, int col) const
ptrdiff_t end_offset_from_storage (int r, int c) const
double * end_address_nc (int row, int col)
const double * end_address (int row, int col) const
const double * storage () const
double * storage_nc ()

Protected Attributes

data_holder m_data


Detailed Description

Adapter class for fitting mtx to the nub::object interface.

Definition at line 45 of file mtxobj.h.


Member Function Documentation

virtual rutz::fstring MtxObj::obj_typename (  )  const [inline, virtual]

Returns the (apparent) typename of the full object.

The default implementation just returns real_typename(). However, certain kinds of objects -- e.g., proxy objects -- might usefully choose to have obj_typename() return something besides the real_typename(), in order to masquerade as a different type of object.

Reimplemented from nub::object.

Definition at line 64 of file mtxobj.h.

mtx mtx::contig (  )  const [inherited]

Makes sure that the data are in contiguous storage; if called on a submatrix, contig() will make a new matrix of the proper size and copy the elements there; otherwise, it will just return the current matrix.

Definition at line 643 of file mtx.cc.

References mtx_base< Data >::colmaj_begin_nc().

nub::uid nub::object::id (  )  const throw () [inherited]

Returns the unique id for this object. The unique id will always be strictly positive; zero is always an invalid unique id.

Definition at line 62 of file object.cc.

rutz::fstring nub::object::real_typename (  )  const [inherited]

Returns the typename of the full object.

The result is a demangled version of typeid(*this).name(), which should very closely resemble the way the object was declared in source code.

Definition at line 67 of file object.cc.

References rutz::demangled_name().

Referenced by nub::object::obj_typename().

void * nub::ref_counted::operator new ( size_t  bytes  )  [inherited]

Class-specific operator new; protected to ensure that clients use factory functions.

Definition at line 157 of file refcounted.cc.

void nub::ref_counted::operator delete ( void *  space,
size_t  bytes 
) [inherited]

Class-specific operator delete; private since deletion should only happen in ref_counted::decr_ref_count.

Definition at line 163 of file refcounted.cc.

void nub::ref_counted::incr_ref_count (  )  const throw () [inherited]

Increment the object's reference count.

This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.

Definition at line 207 of file refcounted.cc.

References nub::ref_counts::acquire_strong().

Referenced by GxEmptyNode::make().

void nub::ref_counted::decr_ref_count (  )  const throw () [inherited]

Decrement the object's reference count.

If this causes the reference count to fall to zero or below, the pointee and the pointer will be destroyed by a call to 'delete this'. This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.

Definition at line 212 of file refcounted.cc.

References nub::ref_counts::release_strong().

void nub::ref_counted::decr_ref_count_no_delete (  )  const throw () [inherited]

Decrement the object's reference count, but don't delete it.

Unlike decr_ref_count(), the object will NOT be delete'd if the reference count falls to zero. This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.

Definition at line 221 of file refcounted.cc.

References nub::ref_counts::release_strong_no_delete().

bool nub::ref_counted::is_shared (  )  const throw () [inherited]

Returns true if no external client has sole ownership of the object.

This may occur if either (1) the reference count is greater than one, or (2) the object is_not_shareable(), meaning that the object itself is the only "owner".

Definition at line 226 of file refcounted.cc.

References rutz::mutex_atomic_int::atomic_get(), nub::ref_counted::is_not_shareable(), and nub::ref_counts::m_strong.

Referenced by nub::ref_counted::is_unshared().

bool nub::ref_counted::is_unshared (  )  const throw () [inherited]

Returns true if there is a sole external owner of the object.

This occurs if the reference count is one or less and the object is shareable.

Definition at line 236 of file refcounted.cc.

References nub::ref_counted::is_shared().

bool nub::ref_counted::is_not_shareable (  )  const throw () [inherited]

Returns true if the object is not shareable for any reason. This could be because its lifespan is volatile (such as objects representing on-screen windows that can be dismissed by the user). The default is for objects to be shareable; objects can declare themselves as unshareable by calling mark_as_volatile().

Definition at line 242 of file refcounted.cc.

References nub::ref_counts::m_volatile.

Referenced by nub::ref_counted::is_shared().


The documentation for this class was generated from the following file:

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:55:37 2008 by Doxygen version 1.5.5.