Giter Club home page Giter Club logo

light-matrix's People

Contributors

lindahua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

light-matrix's Issues

error: expression cannot be used as a function

return m_rowstride() == 1;

dep/light-matrix/light_mat/matrix/matrix_layout.h: In member function ‘bool lmat::grid_layout<M, N>::is_percol_contiguous() const’:
dep/light-matrix/light_mat/matrix/matrix_layout.h:393:23: error: expression cannot be used as a function
    return m_rowstride() == 1;

The above line causes a compilation error, due to the trailing brackets. Removing them gets rid of the error.

Fundamental refactoring

The overall goal is to clarify the modules

  • core ==> common
  • improve accessor concept
  • separate matrix classes, expression classes, and evaluation schemes
  • generalize reduction interfaces

Documentation: user reference

  • common facilities
  • matrix concepts and classes
  • simd and math
  • matrix expressions
  • kernel-based evaluation
  • linear algebra
  • random number generation

STL algorithms on matrices

Utilizing the begin and end iterators, a set of algorithms can be introduced

  • count
  • is_sorted
  • sort
  • partial_sort
  • find_max
  • find_min
  • median

matrix expression casting

The syntax should be like

B = cast(A, type_<T>());

Here,

  • A and B should have the same size.
  • A and B can have different value types
  • When A and B have the same value type, it simply calls evaluate_to

Convenient functions

to_f32(A);
to_f64(A);
to_bool(A); 
...

add argument wrapper

Argument wrapper allows some intermediate expression to be embedded into new expression.

This enables expression creation/transformation functions.

migrate matrix classes

  • matrix base
    • concepts
    • meta-programming kits
    • properties
    • basic operations
  • matrix classes
    • dense_matrix, dense_row, dense_col
    • ref_matrix, ref_row, ref_col
    • ref_matrix_ex

Basic random number generators of distributions

  • Discrete
    • uniform_int_distr
    • bernoulli_distr
    • binomial_distr (a naive version)
    • geometric_distr (a naive version)
    • negative_binomial_distr (a naive version)
    • poisson_distr (a naive version)
    • discrete_distr (a naive version)
  • Continuous
    • uniform_real_distr
    • normal_distr (use ICDF)
    • exponential_distr
    • gamma_distr
    • lognormal_distr

Random matrices

Introduce a set of random matrix expressions

template<class Engine, class Distribution>  class random_expr;

Distr distr;
rand_mat( m, n,  distr, eng ); // ==> random_expr<Eng, Distr>
rand_mat( shape, distr, eng );

randu<T> ( m, n, eng );  // ==> random_expr<Eng, uniform_real_distribution<T> > 
randu<T> ( shape, eng ); 

randn<T> ( m, n, deg ); // ==> random_expr<Eng, normal_distribution<T> >
randn<T> ( shape, eng );

Notes:

  • The value type should be inferrable from Distribution at compile-time.
  • random_expr should implement IEWiseMatrix

generalized range-based indexing

Generalized the IRange concept:

rgn.num();   // --> the number of indices (const)
rgn[i];   // --> the i-th index (const)

range_traits<R>::compile_time_num;

An IMatrixView Class:

class reindexed_matrix<T, RI, RJ>;

ct_rows == range_traits<RI>::compile_time_num;
ct_cols == range_traits<RJ>::compile_time_num;

C(rg0, rg1) returns an instance of reindexed_matrix, except when rg0 and rg1 are some special range.

Documentation: advanced topics

  • architecture of the overall framework
  • how to create new expressions
  • kernel-based evaluation
  • create new random distributions

matrix transpose

  • transpose of vectors
  • transpose of matrices

(no need to optimize at this point)

support for building without exceptions

I think it would be good to allow building with -fno-exceptions, for better or worse this often is a requirement in practice. Would it be possible to make exception support optional?

mask types

  • Introduce a template class, mask_t
  • Element-wise comparison should return matrices of mask_t
  • mask_t is compatible with bool
  • Element-wise logical operations on matrix of mask_t

digamma function

implement and add this function to math_base.h

It is useful for various machine learning models, notably Latent Dirichlet Allocation.

migrate core module

  • basic definitions
  • meta-programming devices
  • memory operations
  • blocks --> arrays
  • range

Vector views

as_col(A)    // map the entire matrix as a column view
as_row(A)   // map the entire matrix as a row view

appliable to all IDenseMatrix classes

element-wise conditional selection

Syntax:

R = cond(Z > 0, X, Y);
R = cond(X > a, a, X);   // in MATLAB:  X(X > a) = a;
  • The first argument must be a mask matrix
  • The second and third argument can be either a matrix or a scalar (of the same type). At least one of them is a matrix.

all* and any* reduction

full and partial reduction with the following functions

all(A, true);
all(A, false);
all(A);   // equivalent to all(A, true);

any(A, true);   
any(A, false);
any(A);   // equivalent to any(A, true); 

colwise_any(A, r, tf);
colwise_all(A, r, tf);

Expression class reflection

Devices to inspect the structure of an expression

The implementation should be non-instrusive, relying on external template class with specializations.

// some declarations

template<class Expr> 
class  matexpr_typeinfo;

template<typename T, class Expr>
matexpr_typeinfo<Expr>  get_matexpr_type(const IMatrixXpr<Expr, T>& )
{
    return matexpr_typeinfo<Expr>();
}

// some usage: let a be an matrix expression instance

// return a type name (e.g. "unary_expr", "dense", etc) as std::string
get_matexpr_type( a ).name();  

// return a short string (e.g. "add(dense, sqr(dense))") as std::string
get_matexpr_type( a ).short_repr();  

Random streams

Introduce a new module: random

Introduce a random stream concept

class IRandStream;

// a model based on std::random

template<class Engine> class std_randstream;

// a model based on SFMT

template<typename Kind> class sfmt_randstream;

// suppose s is an instance of IRandStream

s.rand_i32();  
s.rand_u32();
s.rand_pack( simd_kind );

s.rand_seq( nbytes, buf );

predicate-based finding

Supports the following syntax

find_to(X > 0, it);  // it is an output iterator
find_to(X > 0, v);  // v is an instance of std::vector<index_t>
find_to(X > 0, I, J);  // I and J are both instances of index_seq

idx = find( x > 0 );  // returns an instance of class dense_col<index_t>

Y = select( A, idx );  // idx is any random access container
Y = select( A,  find(x > 0), colon(2, 3) );
  • The find function should accept matrices with bool or mask type.
  • The return type should be index_seq
  • find function should be a simple wrapper of find_to.

MATLAB port

  • const_marray and marray classes
  • interface with cref_matrix and ref_matrix class

begin and end iterators of elements

Introduce begin and end to IRegularMatrix

a.begin()  
a.end()
a.col_begin(j)
a.col_end(j)

begin(a);   // equivalent to a.begin()
end(a);      // equivalent to a.end()

Have both const and non-const versions

Polynomial expression

Syntax should be like:

f = poly(1, 2, 3) // f( x ) = x^2 + 2 * x + 3
f ( 1 ) --> produce a scalar
f ( arr ) --> produce an array through element-wise operation

matrix comparison

matrix comparison functions, which can be implemented using the all function.

is_equal(A, B);  // equivalent to all(A == B);
is_approx(A, B, tol); // equivalent to  all( abs(A - B) < tol );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.