コード例 #1
0
int main( const int argc, const char* const argv[])
{
   if ( argc == 1)
   {
      std::cout << "Usage: ./writeTriangleMesh_Sphere npsi[ positive int ]" << std::endl;
      return 1;
   }

   int npsi = std::atoi( argv[1] );
   if ( npsi <= 1 )
   {
      std::cout << "Error: npsi should be integer larger than 2." << std::endl;
      return 1;
   }
   else
   {
      std::ofstream outobj( "sphere.obj" );
      writeTriangleMesh_Sphere( npsi, outobj );
   }

   return 0;
}
コード例 #2
0
ファイル: viterbidecoder.cpp プロジェクト: icopavan/CRAI
void ViterbiDecoder::Run() {

	int      DataLength, CodeLength, i, j, index;
	int     *g_encoder;
	int      nn, KK, mm, max_states, code_type, dec_type;
	double   elm;
	float   *input_c_float;
	int     *output_u_int;
	int     *out0, *out1, *state0, *state1;


	///////////////////////////////////////////////
	///////////////////////////////////////////////
	///////////////////////////////////////////////

	  /* first input is the data word */
	  gsl_vector_class inputobj = vin1.GetDataObj();
	
	  CodeLength = inputobj.vec->size; /* number of data bits */
	  
	  /* convert the input into float */			
	  input_c_float = (float *)calloc( CodeLength, sizeof(float) );
	  for (i=0;i<CodeLength;i++)
	    input_c_float[i] = gsl_vector_get(inputobj.vec,i);


	  /* default values */
	  code_type = CType();

	  nn = gp_mat->size1;
	  KK = gp_mat->size2;
	  
	  mm = KK - 1;
	  max_states = 1 << mm;			/* 2^mm */
	  
	  /* determine the DataLength */
	  DataLength = (CodeLength/nn)-mm;	

	  /* Convert code polynomial to binary */
	  g_encoder = (int*)calloc(nn, sizeof(int) );
	  
	  for (i = 0;i<nn;i++) {
	    for (j=0;j<KK;j++) {
	      elm = gsl_matrix_get(gp_mat,i,j);
	      if (elm != 0) {
		g_encoder[i] = g_encoder[i] + (int) pow(2,(KK-j-1)); 
	      }
	    }
	  }


	/* create appropriate transition matrices */
	  out0 = (int *)calloc( max_states, sizeof(int) );
	  out1 = (int *)calloc( max_states, sizeof(int) );
	  state0 = (int *)calloc( max_states, sizeof(int) );
	  state1 = (int *)calloc( max_states, sizeof(int) );


	if ( code_type ) {
		nsc_transit( out0, state0, 0, g_encoder, KK, nn );
		nsc_transit( out1, state1, 1, g_encoder, KK, nn );
	} else {
		rsc_transit( out0, state0, 0, g_encoder, KK, nn );
		rsc_transit( out1, state1, 1, g_encoder, KK, nn );
	}

	
	gsl_vector_uint *output = gsl_vector_uint_alloc(DataLength);
	output_u_int = (int *)calloc( DataLength, sizeof(int) );


	/* Run the Viterib algorithm */
	Viterbi( output_u_int, out0, state0, out1, state1,
		input_c_float, KK, nn, DataLength ); 

	/* cast to outputs */
	for (j=0;j<DataLength;j++) {
	  gsl_vector_uint_set(output,j,output_u_int[j]);
	}



	gsl_vector_uint_class outobj(output);
	//	outobj.show();

	vout1.DeliverDataObj(outobj);

	///////////////////////////////////////////////
	///////////////////////////////////////////////
	///////////////////////////////////////////////

	
	/* Clean up memory */
	free( out0 );
	free( out1 );
	free( state0 );
	free( state1 );
	free( g_encoder );
	free( input_c_float );
	free( output_u_int );

	gsl_vector_uint_free(output);


}