Skip to content

Commit

Permalink
SGVectorize dynprog function
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Aug 31, 2011
1 parent 8e2b540 commit 6823fdb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.template
Expand Up @@ -7,7 +7,7 @@
SRCDIR = .

ifeq (../.config,$(wildcard ../.config))
CONFIGPATH = ./
CONFIGPATH = ../
all: build
include ../.config
ifeq (../.config-local,$(wildcard ../.config-local))
Expand Down
15 changes: 5 additions & 10 deletions src/shogun/structure/DynProg.cpp
Expand Up @@ -850,19 +850,14 @@ void CDynProg::get_scores(float64_t **scores, int32_t *m)
memcpy(*scores,m_scores.get_array(), sizeof(float64_t)*(*m));
}

void CDynProg::get_states(int32_t **states, int32_t *m, int32_t *n)
SGMatrix<int32_t> CDynProg::get_states()
{
ASSERT(states && m && n);
SGMatrix<int32_t> states(m_states.get_dim1(), m_states.get_dim2());

*m=m_states.get_dim1() ;
*n=m_states.get_dim2() ;
int32_t sz = sizeof(int32_t)*( m_states.get_dim1() * m_states.get_dim2() );
memcpy(states.matrix ,m_states.get_array(),sz);


*states = SG_MALLOC(int32_t, (*m) * (*n));
ASSERT(*states);

int32_t sz = sizeof(int32_t)*( (*m) * (*n) );
memcpy(*states,m_states.get_array(),sz);
return states;
}

void CDynProg::get_positions(int32_t **positions, int32_t *m, int32_t *n)
Expand Down
6 changes: 2 additions & 4 deletions src/shogun/structure/DynProg.h
Expand Up @@ -254,11 +254,9 @@ class CDynProg : public CSGObject

/** best path get states
*
* @param states states
* @param m dimension m
* @param n dimension n
* @return states states
*/
void get_states(int32_t **states, int32_t *m, int32_t *n);
SGMatrix<int32_t> get_states();

/** best path get positions
*
Expand Down
8 changes: 3 additions & 5 deletions src/shogun/ui/SGInterface.cpp
Expand Up @@ -6770,9 +6770,7 @@ bool CSGInterface::cmd_best_path_trans()
h->get_scores(&p_prob, &n_prob);

int32_t* my_path;
int32_t n_path;
int32_t m_path;
h->get_states(&my_path, &n_path, &m_path);
SGMatrix<int32_t> states=h->get_states();

int32_t* my_pos;
int32_t n_pos;
Expand All @@ -6787,11 +6785,11 @@ bool CSGInterface::cmd_best_path_trans()
{
for (int32_t i=0; i<M; i++)
{
d_my_path[i*(nbest+nother)+k] = my_path[i+k*M] ;
d_my_path[i*(nbest+nother)+k] = states.matrix[i+k*M] ;
d_my_pos[i*(nbest+nother)+k] = my_pos[i+k*M] ;
}
}
free(my_path);
free(states.matrix);
free(my_pos);

set_vector(p_prob,nbest+nother);
Expand Down

0 comments on commit 6823fdb

Please sign in to comment.