当前位置: 首页>>代码示例>>C++>>正文


C++ matrix::size2方法代码示例

本文整理汇总了C++中boost::numeric::ublas::matrix::size2方法的典型用法代码示例。如果您正苦于以下问题:C++ matrix::size2方法的具体用法?C++ matrix::size2怎么用?C++ matrix::size2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost::numeric::ublas::matrix的用法示例。


在下文中一共展示了matrix::size2方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getTrajectoryKeyPosition

void getTrajectoryKeyPosition(double * trajectoryKeyPositions)
{
  for (unsigned int i = 0; i < TRAJECTORYKEYPOSITIONS.size1()*TRAJECTORYKEYPOSITIONS.size2(); i++)
    trajectoryKeyPositions[i] = TRAJECTORYKEYPOSITIONS(i % (TRAJECTORYKEYPOSITIONS.size1()), i / (TRAJECTORYKEYPOSITIONS.size1()));
}
开发者ID:radarsat1,项目名称:siconos,代码行数:5,代码来源:ActuationModelSomeDefinitions.cpp

示例2: return

 BOOST_UBLAS_INLINE
 int matrix_stride2 (const ublas::matrix<M,F,A> &m) {
   return (int) F::one2 (m.size1(), m.size2());
 }
开发者ID:cephdon,项目名称:OMCompiler,代码行数:4,代码来源:matrix_raw.hpp

示例3: getNumberOfKeyPositions

void getNumberOfKeyPositions(int * size)
{
  *size = TRAJECTORYKEYPOSITIONS.size2();
}
开发者ID:radarsat1,项目名称:siconos,代码行数:4,代码来源:ActuationModelSomeDefinitions.cpp

示例4: max

template <typename T> inline T norm_max(ublas::matrix<T>& M) {
	size_t n1 = M.size1();   size_t n2 = M.size2();   T m = 0;
	for (size_t i=0; i<n1; i++)  for (size_t j=0; j<n2; j++)
		m = max(M(i,j),m);
	return m;
}
开发者ID:burdges,项目名称:PathMeasure,代码行数:6,代码来源:pathmeasure.cpp

示例5: gnuplot_printer

void print_matrices_error
	(
	const std::vector<double>& pel_time
	, const std::vector<double>& pel_libor
	, const boost::numeric::ublas::matrix<double>& quote_error_l2
	, const boost::numeric::ublas::matrix<double>& quote_error_l1
	, const boost::numeric::ublas::matrix<double>& quote_error_linf
	, const boost::numeric::ublas::matrix<double>& pel_timehomo_error_l2
	, const boost::numeric::ublas::matrix<double>& pel_timehomo_error_l1
	, const boost::numeric::ublas::matrix<double>& pel_timehomo_error_linf
	, const boost::numeric::ublas::matrix<double>& pel_liborsmoth_error_l2
	, const boost::numeric::ublas::matrix<double>& pel_liborsmoth_error_l1
	, const boost::numeric::ublas::matrix<double>& pel_liborsmoth_error_linf
	)
{
	{ /// print to excel file

		size_t nbPelTime  = quote_error_l2.size1();
		size_t nbPelLibor = quote_error_l2.size2();

		std::string  all_error_file_name = "all_Regularization_Result.csv";
		std::string full_common_result_file = LMMPATH::get_Root_OutputPath() + all_error_file_name ;
		std::ofstream final_result ;

		final_result.open( full_common_result_file.c_str() );
		final_result<<"PelTime\\PelLibor ,,";
		for(size_t j=0;j<nbPelLibor;++j){ final_result<< pel_libor[j]<<" ,,"; } final_result<<std::endl;

		for(size_t iT=0;iT<nbPelTime;++iT)
		{
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<quote_error_l2(iT,jL)<<" ,,"; } final_result<<" L2 Quote Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<quote_error_l1(iT,jL)<<" ,,"; } final_result<<" L1 Quote Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<quote_error_linf(iT,jL)<<" ,,"; } final_result<<" L_INF Quote Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<pel_timehomo_error_l2(iT,jL)<<" ,,"; } final_result<<" L2 Pel Time Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<pel_timehomo_error_l1(iT,jL)<<" ,,"; } final_result<<" L1 Pel Time Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<pel_timehomo_error_linf(iT,jL)<<" ,,"; } final_result<<" L_INF Pel Time Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<pel_liborsmoth_error_l2(iT,jL)<<" ,,"; } final_result<<" L2 Pel Libor Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<pel_liborsmoth_error_l1(iT,jL)<<" ,,"; } final_result<<" L1 Pel Libor Error ,"<<std::endl;
			final_result<<pel_time[iT]<<" ,," ; for(size_t jL=0;jL<nbPelLibor;++jL)	{ final_result<<pel_liborsmoth_error_linf(iT,jL)<<" ,,"; } final_result<<" L_INF Pel Libor Error ,"<<std::endl;

			final_result<<std::endl;
		}
		final_result<<std::endl<<std::endl;
		final_result.close();
	}

	{
		/// print in gnuplot format
		LmmGnuplotPrinterMatrix gnuplot_printer( create___LMMTenorStructure_PTR( 16 ) );
		gnuplot_printer.printFullMatrix(quote_error_l2 , pel_time,pel_libor , "gnuplot_quote_error_l2");
		gnuplot_printer.printFullMatrix(quote_error_l1 , pel_time,pel_libor , "gnuplot_quote_error_l1");
		gnuplot_printer.printFullMatrix(quote_error_linf , pel_time,pel_libor , "gnuplot_quote_error_linf");

		gnuplot_printer.printFullMatrix(pel_timehomo_error_l2 , pel_time,pel_libor , "gnuplot_pel_timehomo_error_l2");
		gnuplot_printer.printFullMatrix(pel_timehomo_error_l1 , pel_time,pel_libor , "gnuplot_pel_timehomo_error_l1");
		gnuplot_printer.printFullMatrix(pel_timehomo_error_linf , pel_time,pel_libor , "gnuplot_pel_timehomo_error_linf");

		gnuplot_printer.printFullMatrix(pel_liborsmoth_error_l2 , pel_time,pel_libor , "gnuplot_pel_liborsmoth_error_l2");
		gnuplot_printer.printFullMatrix(pel_liborsmoth_error_l1 , pel_time,pel_libor , "gnuplot_pel_liborsmoth_error_l1");
		gnuplot_printer.printFullMatrix(pel_liborsmoth_error_linf , pel_time,pel_libor , "gnuplot_pel_liborsmoth_error_linf");
	}
}
开发者ID:JBLMM,项目名称:LMM,代码行数:62,代码来源:Test_LmmRegularizedCalibrationMarketData.cpp

示例6: x

boost::numeric::ublas::vector<double> gradient_descent(boost::numeric::ublas::matrix<double>& x, boost::numeric::ublas::vector<double>& y, double epsilon, double gamma, int max_iters) {

	int iter = 1;
	
	boost::numeric::ublas::vector<double> weight_old(x.size2());
	for (size_t i = 0; i < weight_old.size(); i++) 
		weight_old(i) = 0;
	
	cout << "old weight: " << weight_old << endl;
	
	boost::numeric::ublas::vector<double> weight_new(x.size2());
	for (size_t i = 0; i < weight_new.size(); i++) 
		weight_new(i) = 0;
	
	cout << "new weight: " << weight_new << endl;

	
	while(true) {
		for (size_t k = 0; k < weight_new.size(); k++) {
			double gradient = 0;
			for (size_t i = 0; i < x.size1(); i++) {
				double z_i = 0;
				for (size_t j = 0; j < weight_old.size(); j++) {
					// w^T * x
					z_i += weight_old(j) * x(i, j);
				}

				gradient = y(i) * x(i, k) * sigmoid(-y(i) * z_i);
			}
			
			weight_new(k) = weight_old(k) + gamma * gradient;	
		}

		double dist = norm(weight_new, weight_old);

		if (dist < epsilon){ 
			cout << "The best weight is:" << weight_new << endl;
			cout << "After " << iter << " th iteration" << endl;
			break;
		}
		else
			weight_old.swap(weight_new);

		iter += 1;

		if (iter >= max_iters) {
			cout << "The best weight is:" << weight_new << endl;
			cout << "After " << iter << " th iteration" << endl;

			break;
		}

		cout << "===========================================" << endl;
		cout << "The " << iter << " th iteration, weight:" << endl;
		cout << weight_new << endl << endl;
		cout << "The best weight:" << endl;
		cout << "ending" << endl;
	}	

	return weight_new;
}
开发者ID:irwenqiang,项目名称:liblinear,代码行数:61,代码来源:gradient_descent.hpp

示例7: printFullMatrix

void LmmGnuplotPrinterMatrix::printFullMatrix(const boost::numeric::ublas::matrix<double>& matrix
											  , const std::vector<double>& xticks
											  , const std::vector<double>& yticks
											  ,const std::string& base_filename) const
{
	assert(xticks.size() == matrix.size2() );
	assert(yticks.size() == matrix.size1() );


	{//print matrix data files
		std::string data_file_name = get_dataFileName( base_filename);

		std::string path_OutPut = LMMPATH::get_output_path() + data_file_name;

		std::ofstream matrix_data_file ;
		matrix_data_file.open(path_OutPut.c_str() );
		matrix_data_file<<"### Lmm Matrix output for gnuplot printing surface"<<std::endl;
		matrix_data_file<<"### grid xtics ";for(size_t i=0;i<xticks.size();++i){ matrix_data_file<<", "<<xticks[i]; }
		matrix_data_file<<std::endl;
		matrix_data_file<<"### grid ytics ";for(size_t i=0;i<yticks.size();++i){ matrix_data_file<<", "<<yticks[i]; }

		for(size_t i=0;i<matrix.size1();++i)
		{
			const double x_value = xticks[i] ;
			for(size_t j=0;j<matrix.size2();++j)
			{							
				const double y_value = yticks[j];
				const double z_value = matrix(i,j);
				matrix_data_file<<"	"<<x_value<<"	"<<y_value<<"	"<<z_value<<std::endl;
			}	
			matrix_data_file<<std::endl;
		}

		matrix_data_file.close();
	}

	{// print gnuplot file
		std::string gp_file_name = get_gnuplotFileName(base_filename);

		std::string path_OutPut = LMMPATH::get_output_path() + gp_file_name;

		std::ofstream gnuplot_file ;
		gnuplot_file.open(path_OutPut.c_str() );

		gnuplot_file<<"### gnuplot file"<<std::endl;
		gnuplot_file<<"### grid xtics ";for(size_t i=0;i<xticks.size();++i){ gnuplot_file<<", "<<xticks[i]; }
		gnuplot_file<<std::endl;
		gnuplot_file<<"### grid ytics ";for(size_t i=0;i<yticks.size();++i){ gnuplot_file<<", "<<yticks[i]; }


		gnuplot_file<<"set xlabel \"xLabel\""<<std::endl;
		gnuplot_file<<"set ylabel \"yLabel\""<<std::endl;
		gnuplot_file<<"set title \"Graph title\" "<<std::endl;
		gnuplot_file<<"set style data lines"<<std::endl;
		gnuplot_file<<"set hidden3d"<<std::endl;
		gnuplot_file<<"set pm3d ; set palette"<<std::endl;
		gnuplot_file<<"set cntrparam levels 10"<<std::endl;
		gnuplot_file<<"set contour base"<<std::endl;
		
		std::string data_file_name = get_dataFileName(base_filename);

		gnuplot_file<<"splot \""<< data_file_name <<"\"" <<std::endl;

		gnuplot_file<<"pause -1 \" Hit return to save image\" "<<std::endl;

		gnuplot_file<<"set terminal postscript eps"<<std::endl;

		std::string image_file_name = get_imageFileName(base_filename);

		gnuplot_file<<"set output \""<<image_file_name <<"\""<<std::endl;

		gnuplot_file<<"replot"<<std::endl;

		gnuplot_file.close();
	}
}
开发者ID:JBLMM,项目名称:LMM,代码行数:76,代码来源:LmmGnuplotPrinterMatrix.cpp


注:本文中的boost::numeric::ublas::matrix::size2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。