/** @brief	pd[K]/pd[log(sigma_f)]: (NxN) partial derivative of K with respect to log(sigma_f). */  
TEST_F(TestCaseCovSEisoDerObs, dKdlogsigmafTest)
{
	// Expected value
	Matrix K1(17, 17);
	K1 <<  4.500000000000000f,  2.391566843033882f,  2.068258413742825f,  1.213652802156266f,  1.213652802156266f, -0.209096581849906f,  0.856859986591163f,  3.398287806185042f,  0.856859986591163f, -2.815172813895416f, -2.184927692892753f, -1.861603949298088f, -2.184927692892753f, -1.352959382701566f, -2.337043600836392f,  0.654092153690374f, -2.337043600836392f, 
		    2.391566843033882f,  4.500000000000000f,  1.788691088007260f,  2.127045153645877f,  2.127045153645877f, -1.520517938136889f, -1.684042327850136f,  1.944745188594059f, -1.684042327850136f, -2.266587596380865f, -3.898996151103107f, -3.053453891816892f, -3.898996151103107f, -0.250811316270990f, -2.229231424290288f,  3.743868993277220f, -2.229231424290288f, 
			 2.068258413742825f,  1.788691088007260f,  4.500000000000000f,  2.787417058819007f,  2.787417058819007f, -2.815528298077105f, -0.195079181660578f,  4.951717610715929f, -0.195079181660578f, -2.231418108982969f, -0.132639292997839f,  2.045688565044857f, -0.132639292997839f, -3.869492976477300f, -4.916767803906841f,  1.032839204317740f, -4.916767803906841f, 
			 1.213652802156266f,  2.127045153645877f,  2.787417058819007f,  4.500000000000000f,  4.500000000000000f, -1.690080498588427f, -1.577774516643144f,  0.000000000000000f, -1.577774516643144f, -0.965117603183367f, -0.675520816547556f,  0.000000000000000f, -0.675520816547556f, -1.172578173777774f, -2.549412610403244f,  0.000000000000000f, -2.549412610403244f, 
			 1.213652802156266f,  2.127045153645877f,  2.787417058819007f,  4.500000000000000f,  4.500000000000000f, -1.690080498588427f, -1.577774516643144f,  0.000000000000000f, -1.577774516643144f, -0.965117603183367f, -0.675520816547556f,  0.000000000000000f, -0.675520816547556f, -1.172578173777774f, -2.549412610403244f,  0.000000000000000f, -2.549412610403244f, 
			-0.209096581849906f, -1.520517938136889f, -2.815528298077105f, -1.690080498588427f, -1.690080498588427f,  18.000000000000000f,  8.122578633520462f, -2.921433316901480f,  8.122578633520462f,  0.000000000000000f, -3.310965475811941f, -2.936899174830953f, -3.310965475811941f,  0.000000000000000f,  3.306197914360069f, -3.568211645538123f,  3.306197914360069f, 
			 0.856859986591163f, -1.684042327850136f, -0.195079181660578f, -1.577774516643144f, -1.577774516643144f,  8.122578633520462f,  18.000000000000000f,  0.382565397655461f,  18.000000000000000f, -3.310965475811941f,  0.000000000000000f, -1.271624294680698f,  0.000000000000000f,  3.306197914360069f,  0.000000000000000f, -4.799104532592702f,  0.000000000000000f, 
			 3.398287806185042f,  1.944745188594059f,  4.951717610715929f,  0.000000000000000f,  0.000000000000000f, -2.921433316901480f,  0.382565397655461f,  18.000000000000000f,  0.382565397655461f, -2.936899174830953f, -1.271624294680698f,  0.000000000000000f, -1.271624294680698f, -3.568211645538123f, -4.799104532592702f,  0.000000000000000f, -4.799104532592702f, 
			 0.856859986591163f, -1.684042327850136f, -0.195079181660578f, -1.577774516643144f, -1.577774516643144f,  8.122578633520462f,  18.000000000000000f,  0.382565397655461f,  18.000000000000000f, -3.310965475811941f,  0.000000000000000f, -1.271624294680698f,  0.000000000000000f,  3.306197914360069f,  0.000000000000000f, -4.799104532592702f,  0.000000000000000f, 
			-2.815172813895416f, -2.266587596380865f, -2.231418108982969f, -0.965117603183367f, -0.965117603183367f,  0.000000000000000f, -3.310965475811941f, -2.936899174830953f, -3.310965475811941f,  18.000000000000000f,  9.588611785945304f,  0.544451439602559f,  9.588611785945304f,  0.000000000000000f,  2.654292256005079f, -2.037621210273108f,  2.654292256005079f, 
			-2.184927692892753f, -3.898996151103107f, -0.132639292997839f, -0.675520816547556f, -0.675520816547556f, -3.310965475811941f,  0.000000000000000f, -1.271624294680698f,  0.000000000000000f,  9.588611785945304f,  18.000000000000000f,  2.808180744428068f,  18.000000000000000f,  2.654292256005079f,  0.000000000000000f, -2.054726438003018f,  0.000000000000000f, 
			-1.861603949298088f, -3.053453891816892f,  2.045688565044857f,  0.000000000000000f,  0.000000000000000f, -2.936899174830953f, -1.271624294680698f,  0.000000000000000f, -1.271624294680698f,  0.544451439602559f,  2.808180744428068f,  18.000000000000000f,  2.808180744428068f, -2.037621210273108f, -2.054726438003018f,  0.000000000000000f, -2.054726438003018f, 
			-2.184927692892753f, -3.898996151103107f, -0.132639292997839f, -0.675520816547556f, -0.675520816547556f, -3.310965475811941f,  0.000000000000000f, -1.271624294680698f,  0.000000000000000f,  9.588611785945304f,  18.000000000000000f,  2.808180744428068f,  18.000000000000000f,  2.654292256005079f,  0.000000000000000f, -2.054726438003018f,  0.000000000000000f, 
			-1.352959382701566f, -0.250811316270990f, -3.869492976477300f, -1.172578173777774f, -1.172578173777774f,  0.000000000000000f,  3.306197914360069f, -3.568211645538123f,  3.306197914360069f,  0.000000000000000f,  2.654292256005079f, -2.037621210273108f,  2.654292256005079f,  18.000000000000000f,  9.596261292094390f, -0.254063189553142f,  9.596261292094390f, 
			-2.337043600836392f, -2.229231424290288f, -4.916767803906841f, -2.549412610403244f, -2.549412610403244f,  3.306197914360069f,  0.000000000000000f, -4.799104532592702f,  0.000000000000000f,  2.654292256005079f,  0.000000000000000f, -2.054726438003018f,  0.000000000000000f,  9.596261292094390f,  18.000000000000000f, -4.401904608169719f,  18.000000000000000f, 
			 0.654092153690374f,  3.743868993277220f,  1.032839204317740f,  0.000000000000000f,  0.000000000000000f, -3.568211645538123f, -4.799104532592702f,  0.000000000000000f, -4.799104532592702f, -2.037621210273108f, -2.054726438003018f,  0.000000000000000f, -2.054726438003018f, -0.254063189553142f, -4.401904608169719f,  18.000000000000000f, -4.401904608169719f, 
			-2.337043600836392f, -2.229231424290288f, -4.916767803906841f, -2.549412610403244f, -2.549412610403244f,  3.306197914360069f,  0.000000000000000f, -4.799104532592702f,  0.000000000000000f,  2.654292256005079f,  0.000000000000000f, -2.054726438003018f,  0.000000000000000f,  9.596261292094390f,  18.000000000000000f, -4.401904608169719f,  18.000000000000000f;

	// Actual value
	MatrixPtr pK2 = CovSEisoDerObs<TestType>::K(logHyp, derivativeTrainingData, 1);

	// Test
	TEST_MACRO::COMPARE(K1, *pK2, __FILE__, __LINE__);
}
/** @brief	K: (NxN) self covariance matrix between the training data. */  
TEST_F(TestCaseCovSEisoDerObs, KTest)
{
	// Expected value
	Matrix K1(17, 17);
	K1 <<  2.250000000000000f,  1.195783421516941f,  1.034129206871412f,  0.606826401078133f,  0.606826401078133f, -0.104548290924953f,  0.428429993295581f,  1.699143903092521f,  0.428429993295581f, -1.407586406947708f, -1.092463846446376f, -0.930801974649044f, -1.092463846446376f, -0.676479691350783f, -1.168521800418196f,  0.327046076845187f, -1.168521800418196f, 
		    1.195783421516941f,  2.250000000000000f,  0.894345544003630f,  1.063522576822939f,  1.063522576822939f, -0.760258969068444f, -0.842021163925068f,  0.972372594297029f, -0.842021163925068f, -1.133293798190432f, -1.949498075551553f, -1.526726945908446f, -1.949498075551553f, -0.125405658135495f, -1.114615712145144f,  1.871934496638610f, -1.114615712145144f, 
			 1.034129206871412f,  0.894345544003630f,  2.250000000000000f,  1.393708529409504f,  1.393708529409504f, -1.407764149038552f, -0.097539590830289f,  2.475858805357964f, -0.097539590830289f, -1.115709054491484f, -0.066319646498920f,  1.022844282522428f, -0.066319646498920f, -1.934746488238650f, -2.458383901953420f,  0.516419602158870f, -2.458383901953420f, 
			 0.606826401078133f,  1.063522576822939f,  1.393708529409504f,  2.250000000000000f,  2.250000000000000f, -0.845040249294214f, -0.788887258321572f,  0.000000000000000f, -0.788887258321572f, -0.482558801591683f, -0.337760408273778f,  0.000000000000000f, -0.337760408273778f, -0.586289086888887f, -1.274706305201622f,  0.000000000000000f, -1.274706305201622f, 
			 0.606826401078133f,  1.063522576822939f,  1.393708529409504f,  2.250000000000000f,  2.250000000000000f, -0.845040249294214f, -0.788887258321572f,  0.000000000000000f, -0.788887258321572f, -0.482558801591683f, -0.337760408273778f,  0.000000000000000f, -0.337760408273778f, -0.586289086888887f, -1.274706305201622f,  0.000000000000000f, -1.274706305201622f, 
			-0.104548290924953f, -0.760258969068444f, -1.407764149038552f, -0.845040249294214f, -0.845040249294214f,  9.000000000000000f,  4.061289316760231f, -1.460716658450740f,  4.061289316760231f,  0.000000000000000f, -1.655482737905971f, -1.468449587415477f, -1.655482737905971f,  0.000000000000000f,  1.653098957180035f, -1.784105822769061f,  1.653098957180035f, 
			 0.428429993295581f, -0.842021163925068f, -0.097539590830289f, -0.788887258321572f, -0.788887258321572f,  4.061289316760231f,  9.000000000000000f,  0.191282698827731f,  9.000000000000000f, -1.655482737905971f,  0.000000000000000f, -0.635812147340349f,  0.000000000000000f,  1.653098957180035f,  0.000000000000000f, -2.399552266296351f,  0.000000000000000f, 
			 1.699143903092521f,  0.972372594297029f,  2.475858805357964f,  0.000000000000000f,  0.000000000000000f, -1.460716658450740f,  0.191282698827731f,  9.000000000000000f,  0.191282698827731f, -1.468449587415477f, -0.635812147340349f,  0.000000000000000f, -0.635812147340349f, -1.784105822769061f, -2.399552266296351f,  0.000000000000000f, -2.399552266296351f, 
			 0.428429993295581f, -0.842021163925068f, -0.097539590830289f, -0.788887258321572f, -0.788887258321572f,  4.061289316760231f,  9.000000000000000f,  0.191282698827731f,  9.000000000000000f, -1.655482737905971f,  0.000000000000000f, -0.635812147340349f,  0.000000000000000f,  1.653098957180035f,  0.000000000000000f, -2.399552266296351f,  0.000000000000000f, 
			-1.407586406947708f, -1.133293798190432f, -1.115709054491484f, -0.482558801591683f, -0.482558801591683f,  0.000000000000000f, -1.655482737905971f, -1.468449587415477f, -1.655482737905971f,  9.000000000000000f,  4.794305892972652f,  0.272225719801279f,  4.794305892972652f,  0.000000000000000f,  1.327146128002539f, -1.018810605136554f,  1.327146128002539f, 
			-1.092463846446376f, -1.949498075551553f, -0.066319646498920f, -0.337760408273778f, -0.337760408273778f, -1.655482737905971f,  0.000000000000000f, -0.635812147340349f,  0.000000000000000f,  4.794305892972652f,  9.000000000000000f,  1.404090372214034f,  9.000000000000000f,  1.327146128002539f,  0.000000000000000f, -1.027363219001509f,  0.000000000000000f, 
			-0.930801974649044f, -1.526726945908446f,  1.022844282522428f,  0.000000000000000f,  0.000000000000000f, -1.468449587415477f, -0.635812147340349f,  0.000000000000000f, -0.635812147340349f,  0.272225719801279f,  1.404090372214034f,  9.000000000000000f,  1.404090372214034f, -1.018810605136554f, -1.027363219001509f,  0.000000000000000f, -1.027363219001509f, 
			-1.092463846446376f, -1.949498075551553f, -0.066319646498920f, -0.337760408273778f, -0.337760408273778f, -1.655482737905971f,  0.000000000000000f, -0.635812147340349f,  0.000000000000000f,  4.794305892972652f,  9.000000000000000f,  1.404090372214034f,  9.000000000000000f,  1.327146128002539f,  0.000000000000000f, -1.027363219001509f,  0.000000000000000f, 
			-0.676479691350783f, -0.125405658135495f, -1.934746488238650f, -0.586289086888887f, -0.586289086888887f,  0.000000000000000f,  1.653098957180035f, -1.784105822769061f,  1.653098957180035f,  0.000000000000000f,  1.327146128002539f, -1.018810605136554f,  1.327146128002539f,  9.000000000000000f,  4.798130646047195f, -0.127031594776571f,  4.798130646047195f, 
			-1.168521800418196f, -1.114615712145144f, -2.458383901953420f, -1.274706305201622f, -1.274706305201622f,  1.653098957180035f,  0.000000000000000f, -2.399552266296351f,  0.000000000000000f,  1.327146128002539f,  0.000000000000000f, -1.027363219001509f,  0.000000000000000f,  4.798130646047195f,  9.000000000000000f, -2.200952304084860f,  9.000000000000000f, 
			 0.327046076845187f,  1.871934496638610f,  0.516419602158870f,  0.000000000000000f,  0.000000000000000f, -1.784105822769061f, -2.399552266296351f,  0.000000000000000f, -2.399552266296351f, -1.018810605136554f, -1.027363219001509f,  0.000000000000000f, -1.027363219001509f, -0.127031594776571f, -2.200952304084860f,  9.000000000000000f, -2.200952304084860f, 
			-1.168521800418196f, -1.114615712145144f, -2.458383901953420f, -1.274706305201622f, -1.274706305201622f,  1.653098957180035f,  0.000000000000000f, -2.399552266296351f,  0.000000000000000f,  1.327146128002539f,  0.000000000000000f, -1.027363219001509f,  0.000000000000000f,  4.798130646047195f,  9.000000000000000f, -2.200952304084860f,  9.000000000000000f;

	// Actual value
	MatrixPtr pK2 = CovSEisoDerObs<TestType>::K(logHyp, derivativeTrainingData);

	// Test
	TEST_MACRO::COMPARE(K1, *pK2, __FILE__, __LINE__);
}
/** @brief	pd[K]/pd[log(ell)]: (NxN) partial derivative of K with respect to log(ell). */  
TEST_F(TestCaseCovSEisoDerObs, dKdlogellTest)
{
	// Expected value
	Matrix K1(17, 17);
	K1 <<  0.000000000000000f,  1.511777950421784f,  1.607803055808120f,  1.590422503432665f,  1.590422503432665f, -0.136819572858730f,  0.490620635702894f,  1.054973777766396f,  0.490620635702894f, -1.842070963155020f, -1.251045247096330f, -0.577921430763274f, -1.251045247096330f, -0.885291013362025f, -1.338143728322809f,  0.203058160385995f, -1.338143728322809f, 
		    1.511777950421784f,  0.000000000000000f,  1.650234378072228f,  1.593887740837630f,  1.593887740837630f, -1.278091225458310f,  0.083355149460816f, -0.487462765679829f,  0.083355149460816f, -1.905209827525377f,  0.192988858740412f,  0.765367662411835f,  0.192988858740412f, -0.210822729894517f,  0.110340408599872f, -0.938424604163818f,  0.110340408599872f, 
			 1.607803055808120f,  1.650234378072228f,  0.000000000000000f,  1.335066891462005f,  1.335066891462005f,  0.829851523433553f,  0.020690614113166f, -2.580032965599663f,  0.020690614113166f,  0.657690323489699f,  0.014068074329102f, -1.065881447630231f,  0.014068074329102f,  1.140498088276427f,  0.521485401203287f, -0.538148457726413f,  0.521485401203287f, 
			 1.590422503432665f,  1.593887740837630f,  1.335066891462005f,  0.000000000000000f,  0.000000000000000f, -1.845839796972857f, -1.073878203910549f,  -0.000000000000000f, -1.073878203910549f, -1.054063686435530f, -0.459778677831410f,  -0.000000000000000f, -0.459778677831410f, -1.280644004843847f, -1.735202721432949f,  -0.000000000000000f, -1.735202721432949f, 
			 1.590422503432665f,  1.593887740837630f,  1.335066891462005f,  0.000000000000000f,  0.000000000000000f, -1.845839796972857f, -1.073878203910549f,  -0.000000000000000f, -1.073878203910549f, -1.054063686435530f, -0.459778677831410f,  -0.000000000000000f, -0.459778677831410f, -1.280644004843847f, -1.735202721432949f,  -0.000000000000000f, -1.735202721432949f, 
			-0.136819572858730f, -1.278091225458310f,  0.829851523433553f, -1.845839796972857f, -1.845839796972857f, -18.000000000000000f, -0.870317782110254f,  1.952320881723154f, -0.870317782110254f,  0.000000000000000f,  5.346836201280334f, -0.270667199153855f,  5.346836201280334f,  0.000000000000000f, -5.339137126690483f, -0.328849509156732f, -5.339137126690483f, 
			 0.490620635702894f,  0.083355149460816f,  0.020690614113166f, -1.073878203910549f, -1.073878203910549f, -0.870317782110254f, -18.000000000000000f,  3.230443483240851f, -18.000000000000000f,  5.346836201280334f,  0.000000000000000f,  0.406120637969283f,  0.000000000000000f, -5.339137126690483f,  0.000000000000000f,  1.532697513417059f,  0.000000000000000f, 
			 1.054973777766396f, -0.487462765679829f, -2.580032965599663f,  -0.000000000000000f,  -0.000000000000000f,  1.952320881723154f,  3.230443483240851f, -18.000000000000000f,  3.230443483240851f, -0.270667199153855f,  0.406120637969283f,  0.000000000000000f,  0.406120637969283f, -0.328849509156732f,  1.532697513417059f,  0.000000000000000f,  1.532697513417059f, 
			 0.490620635702894f,  0.083355149460816f,  0.020690614113166f, -1.073878203910549f, -1.073878203910549f, -0.870317782110254f, -18.000000000000000f,  3.230443483240851f, -18.000000000000000f,  5.346836201280334f,  0.000000000000000f,  0.406120637969283f,  0.000000000000000f, -5.339137126690483f,  0.000000000000000f,  1.532697513417059f,  0.000000000000000f, 
			-1.842070963155020f, -1.905209827525377f,  0.657690323489699f, -1.054063686435530f, -1.054063686435530f,  0.000000000000000f,  5.346836201280334f, -0.270667199153855f,  5.346836201280334f, -18.000000000000000f, -3.237796147235768f,  2.271739855201187f, -3.237796147235768f,  0.000000000000000f, -4.286382937806295f, -0.187788954638817f, -4.286382937806295f, 
			-1.251045247096330f,  0.192988858740412f,  0.014068074329102f, -0.459778677831410f, -0.459778677831410f,  5.346836201280334f,  0.000000000000000f,  0.406120637969283f,  0.000000000000000f, -3.237796147235768f, -18.000000000000000f,  2.455770919795743f, -18.000000000000000f, -4.286382937806295f,  0.000000000000000f,  0.656221193118736f,  0.000000000000000f, 
			-0.577921430763274f,  0.765367662411835f, -1.065881447630231f,  -0.000000000000000f,  -0.000000000000000f, -0.270667199153855f,  0.406120637969283f,  0.000000000000000f,  0.406120637969283f,  2.271739855201187f,  2.455770919795743f, -18.000000000000000f,  2.455770919795743f, -0.187788954638817f,  0.656221193118736f,  0.000000000000000f,  0.656221193118736f, 
			-1.251045247096330f,  0.192988858740412f,  0.014068074329102f, -0.459778677831410f, -0.459778677831410f,  5.346836201280334f,  0.000000000000000f,  0.406120637969283f,  0.000000000000000f, -3.237796147235768f, -18.000000000000000f,  2.455770919795743f, -18.000000000000000f, -4.286382937806295f,  0.000000000000000f,  0.656221193118736f,  0.000000000000000f, 
			-0.885291013362025f, -0.210822729894517f,  1.140498088276427f, -1.280644004843847f, -1.280644004843847f,  0.000000000000000f, -5.339137126690483f, -0.328849509156732f, -5.339137126690483f,  0.000000000000000f, -4.286382937806295f, -0.187788954638817f, -4.286382937806295f, -18.000000000000000f, -3.250149237806673f,  2.198148047893267f, -3.250149237806673f, 
			-1.338143728322809f,  0.110340408599872f,  0.521485401203287f, -1.735202721432949f, -1.735202721432949f, -5.339137126690483f,  0.000000000000000f,  1.532697513417059f,  0.000000000000000f, -4.286382937806295f,  0.000000000000000f,  0.656221193118736f,  0.000000000000000f, -3.250149237806673f, -18.000000000000000f,  4.758467144976980f, -18.000000000000000f, 
			 0.203058160385995f, -0.938424604163818f, -0.538148457726413f,  -0.000000000000000f,  -0.000000000000000f, -0.328849509156732f,  1.532697513417059f,  0.000000000000000f,  1.532697513417059f, -0.187788954638817f,  0.656221193118736f,  0.000000000000000f,  0.656221193118736f,  2.198148047893267f,  4.758467144976980f, -18.000000000000000f,  4.758467144976980f, 
			-1.338143728322809f,  0.110340408599872f,  0.521485401203287f, -1.735202721432949f, -1.735202721432949f, -5.339137126690483f,  0.000000000000000f,  1.532697513417059f,  0.000000000000000f, -4.286382937806295f,  0.000000000000000f,  0.656221193118736f,  0.000000000000000f, -3.250149237806673f, -18.000000000000000f,  4.758467144976980f, -18.000000000000000f;

	// Actual value
	MatrixPtr pK2 = CovSEisoDerObs<TestType>::K(logHyp, derivativeTrainingData, 0);

	// Test
	TEST_MACRO::COMPARE(K1, *pK2, __FILE__, __LINE__);
}
static double far_error(int P, double minrad)
{
  // this uses an upper bound to all force components and the potential
  double rhores = 2*M_PI*uz*minrad;
  double pref = 4*uz*dmax(1, 2*M_PI*uz);

  return pref*K1(rhores*P)*exp(rhores)/rhores*(P - 1 + 1/rhores);
}
Exemple #5
0
double dNdT(double N,double phie,double T9){
  double dN,z=mecc/kb/T9;//unitless
  double sum=0;//answer and summation portion
  int i;//iteration variable
  for(i=1;i<itNum;i++)
    sum+=pow(-1.,i+1)*sinh(i*phie)*(KN(3,i*z)+K1(i*z));
  dN = -kb/mecc*(2*z*N-z*z*z*z/2.*sum);
  return dN;
}
int test_string_cast_vector()
{
	int Error = 0;
	
	glm::vec2 A1(1, 2);
	std::string A2 = glm::to_string(A1);
	Error += A2 != std::string("fvec2(1.000000, 2.000000)") ? 1 : 0;
	
	glm::vec3 B1(1, 2, 3);
	std::string B2 = glm::to_string(B1);
	Error += B2 != std::string("fvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;

	glm::vec4 C1(1, 2, 3, 4);
	std::string C2 = glm::to_string(C1);
	Error += C2 != std::string("fvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
	
	glm::ivec2 D1(1, 2);
	std::string D2 = glm::to_string(D1);
	Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0;
	
	glm::ivec3 E1(1, 2, 3);
	std::string E2 = glm::to_string(E1);
	Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0;
	
	glm::ivec4 F1(1, 2, 3, 4);
	std::string F2 = glm::to_string(F1);
	Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0;
	
	glm::hvec2 G1(1, 2);
	std::string G2 = glm::to_string(G1);
	Error += G2 != std::string("hvec2(1.0000, 2.0000)") ? 1 : 0;
	
	glm::hvec3 H1(1, 2, 3);
	std::string H2 = glm::to_string(H1);
	Error += H2 != std::string("hvec3(1.0000, 2.0000, 3.0000)") ? 1 : 0;
	
	glm::hvec4 I1(1, 2, 3, 4);
	std::string I2 = glm::to_string(I1);
	Error += I2 != std::string("hvec4(1.0000, 2.0000, 3.0000, 4.0000)") ? 1 : 0;
	
	glm::dvec2 J1(1, 2);
	std::string J2 = glm::to_string(J1);
	Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0;
	
	glm::dvec3 K1(1, 2, 3);
	std::string K2 = glm::to_string(K1);
	Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;
	
	glm::dvec4 L1(1, 2, 3, 4);
	std::string L2 = glm::to_string(L1);
	Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
	
	return Error;
}
Exemple #7
0
void bessel_k(_FLOAT_ x, _FLOAT_ k[], int n)
{
     int l;
     _FLOAT_ one_over_x;

     one_over_x = 1.0/x;
     k[0] = K0(x); 
     k[1] = K1(x);
     for (l=2; l<n; l++) {
         k[l] = (2*l-2)*k[l-1]*one_over_x + k[l-2];
     }
}     
Exemple #8
0
double KN(int n, double x){//Modified Bessel function of the second kindlol
  int i;
  double k0=K0(x),k1=K1(x),kn=0;
  if(n==0)return k0;
  else if(n==1)return k1;
  for(i=1;i<n;i++){
    kn = k0+(2./x)*i*k1;
    k0=k1;
    k1=kn;
  }
  return kn;
}
Exemple #9
0
static
V
calc_edge_score(const boost::multi_array<V,2>& si_subst,
		const std::vector<V>& gap,
		const Data& xx, const Data& yy,
		uint x_i, uint x_j, uint y_i, uint y_j)
{
  typedef V value_type;
  typedef typename Data::Seq Seq;
  typedef boost::multi_array<value_type,2> dp_type;
  const Seq& x(xx.seq);
  const Seq& y(yy.seq);
  const std::vector<float>& w_x(xx.weight);
  const std::vector<float>& w_y(yy.weight);
  uint sz_x = x_i<=x_j ? x_j-x_i+1 : 0;
  uint sz_y = y_i<=y_j ? y_j-y_i+1 : 0;

  if (sz_x==0) { return gap[sz_y]; }
  if (sz_y==0) { return gap[sz_x]; }

  dp_type K0(boost::extents[sz_x+1][sz_y+1]);
  dp_type G0(boost::extents[sz_x+1][sz_y+1]);
  std::vector<value_type> K1(sz_y+1);
  std::vector<value_type> G1(sz_y+1);

  K0[0][0] = G0[0][0] = 1.0;
  for (uint i=1; i!=sz_x+1; ++i) {
    K0[i][0] = 1.0;
    G0[i][0] = G0[i-1][0]*gap[1];
  }
  for (uint j=1; j!=sz_y+1; ++j) {
    K0[0][j] = 1.0;
    G0[0][j] = G0[0][j-1]*gap[1];
  }

  for (uint i=1; i!=sz_x+1; ++i) {
    K1[0] = G1[0] = 0.0;
    uint ii=x_i+i;
    for (uint j=1; j!=sz_y+1; ++j) {
      uint jj=y_i+j;
      value_type v = G0[i-1][j-1];
      v *= subst_score(si_subst,x[ii-1],y[jj-1]);
      v *= w_x[ii-1]*w_y[jj-1];
      K1[j] = v + K1[j-1];
      G1[j] = v + G1[j-1]*gap[1];
      K0[i][j] = K1[j] + K0[i-1][j];
      G0[i][j] = G1[j] + G0[i-1][j]*gap[1];
    }
  }

  return K0[sz_x][sz_y];
}
void main(void){     // Животные - непарнокопытные: лошади,зебры,ослы
{ clrscr();
	Animal A("неизвестное");
	Solipeds S("Чудо"), S2("Мистер_Х");
	Horse H("Пегас"), H2("Мустанг");
	Zebra K("Хабл"), K1("Форидка");
	Donkey D("Гавр"), D2("МегаМозг");
	cout<<"\nD ты кто? ";S.WhoAreYou();
	cout<<"\nT ты кто? ";H.WhoAreYou();
	cout<<endl;
}
	getchar();
}//======================================================================
Exemple #11
0
void bessel_k_scaled(_FLOAT_ x, _FLOAT_ k[], int n)
/* computes k_n(x)*x^(n+1) */
{
     int l;
     _FLOAT_ x2;

     x2 = x*x;
     k[0] = K0(x)*x;
     k[1] = K1(x)*x2;
     for (l=2; l<n; l++) {
         k[l] = (2*l-2)*k[l-1] + x2*k[l-2];
     }
}
// Private members
std::vector<float> physics::RK2(float t, const std::vector<float>& x)
{
  size_t i,max=x.size();
  std::vector<float> a,b,ret=x;
  a = K1(t,x);
  b = K2(t,x,a);

  for(i=0;i<max;i++)
    {
      ret[i]=x[i]+(a[i]*0.5+b[i]*0.5)*h;
    }
  return ret;
}
Exemple #13
0
Dialog2::Dialog2(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog2)
{
    ui->setupUi(this);

    connect(ui->lineEdit,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(a(QString)));
    connect(ui->lineEdit_2,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(b(QString)));
    connect(ui->lineEdit_3,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(c(QString)));
    connect(ui->lineEdit_4,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(d(QString)));
    connect(ui->pushButton_2,SIGNAL(clicked()),ui->pushButton_2,SLOT(przeslij()));
    connect(ui->pushButton_2,SIGNAL(wyslij(double,double,double,double,double,double,double,double)),this,SLOT(moje(double,double,double,double,double,double,double,double)));
    connect(ui->lineEdit_5,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(w11(QString)));
    connect(ui->lineEdit_6,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(w21(QString)));
    connect(ui->lineEdit_7,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(czas1(QString)));
    connect(ui->lineEdit_8,SIGNAL(textChanged(QString)),ui->pushButton_2,SLOT(K1(QString)));
}
//======================================================================
tensor EightNode_Brick_u_p::getStiffnessTensorQ( )
{
    int K1_dim[] = {Num_Nodes, Num_Dim, Num_Nodes};
    tensor K1(3,K1_dim,0.0);
    tensor Kk1(3,K1_dim,0.0);

    double r  = 0.0;
    double rw = 0.0;
    double s  = 0.0;
    double sw = 0.0;
    double t  = 0.0;
    double tw = 0.0;
    double weight = 0.0;
    double det_of_Jacobian = 1.0;

    int h_dim[] = {Num_Nodes,Num_Dim};
    tensor h(2, h_dim, 0.0);

    tensor Jacobian;
    tensor dhGlobal;

    int GP_c_r, GP_c_s, GP_c_t;

    for( GP_c_r = 0 ; GP_c_r < Num_IntegrationPts; GP_c_r++ ) {
      r = pts[GP_c_r];
      rw = wts[GP_c_r];
      for( GP_c_s = 0 ; GP_c_s < Num_IntegrationPts; GP_c_s++ ) {
        s = pts[GP_c_s];
        sw = wts[GP_c_s];
        for( GP_c_t = 0 ; GP_c_t < Num_IntegrationPts; GP_c_t++ ) {
          t = pts[GP_c_t];
          tw = wts[GP_c_t];
          Jacobian = this->Jacobian_3D(r,s,t);
          det_of_Jacobian  = Jacobian.determinant();
	  weight = rw * sw * tw * det_of_Jacobian ;
	  h = shapeFunction(r,s,t);
	  dhGlobal = this->dh_Global(r,s,t);
	  Kk1 = dhGlobal("ai")*h("k");
	  K1 += Kk1*(weight*alpha);
	}
      }
    }
    
    return K1;
}
Exemple #15
0
/*** contributions from the mirror image HIII ***/
static double
strikexHIII (MagComp component, const fault_params *fault, const magnetic_params *mag, double xi, double et, double qq, double y, double z)
{
	double val;
	double h = mag->dcurier;
	double qd = y * sd + (fault->fdepth - h) * cd;
	double K1_val = K1 (component, 1.0, xi, et, qq);
	double atan_xe_qr_val = atan_xe_qr (component, 1.0, xi, et, qq);
	double J1_val = J1 (component, 1.0, xi, et, qq);
	double M1_val = M1 (component, 1.0, xi, et, qq);
	double L1_val = L1 (component, 1.0, xi, et, qq);

	val = - alpha4 * K1_val
		+ alpha1 * atan_xe_qr_val + alpha3 * J1_val
		+ alpha3 * (qd * M1_val + (z - h) * L1_val * sd);

	return val;
}
Exemple #16
0
double determine_bessel_cutoff(double switch_rad, double maxPWerror, int maxP)
{
  /* this calculates an upper bound to all force components and the potential */

  // fprintf(stderr, "determ: %f %f %d\n", switch_rad, maxPWerror, maxP);

  double err;
  double rhores = 2*M_PI*uz*switch_rad;
  double pref = 4*uz*dmax(1, 2*M_PI*uz);
  int P = 1;
  do {
    err = pref*K1(rhores*P)*exp(rhores)/rhores*(P - 1 + 1/rhores);
    // fprintf(stderr, "%d %e\n", P, err); */
    P++;
  } while (err > maxPWerror && P <= maxP);
  P--;
  return P;
}
Exemple #17
0
// Runge-Kutta 4 algorithm
void System::RK4(){
    vec2dN K1(nObj), K2(nObj), K3(nObj), K4(nObj);
    vec2dN L1(nObj), L2(nObj), L3(nObj), L4(nObj);

    vec2dN NewR(nObj), NewV(nObj);
    if (nObj == 1){ // If only ONE object
        K1 = h*derX(vec2dN(nObj));
        L1 = h*(SunInf(vec2dN(nObj)));
        K2 = h*derX(L1*0.5);
        L2 = h*(SunInf(K1*0.5));
        K3 = h*derX(L2*0.5);
        L3 = h*(SunInf(K2*0.5));
        K4 = h*derX(L3);
        L4 = h*(SunInf(K3));
    } else { // If more than one object
        if (!statSun){ // Sun mobile or not pressent
            K1 = h*derX(vec2dN(nObj));
            L1 = h*derV(vec2dN(nObj));
            K2 = h*derX(L1*0.5);
            L2 = h*derV(K1*0.5);
            K3 = h*derX(L2*0.5);
            L3 = h*derV(L2*0.5);
            K4 = h*derX(L3);
            L4 = h*derV(K4);
        } else { // If the sun is stationary
            K1 = h*derX(vec2dN(nObj));
            L1 = h*(derV(vec2dN(nObj)) + SunInf(vec2dN(nObj)));
            K2 = h*derX(L1*0.5);
            L2 = h*(derV(K1*0.5) + SunInf(K1*0.5));
            K3 = h*derX(L2*0.5);
            L3 = h*(derV(K2*0.5) + SunInf(K2*0.5));
            K4 = h*derX(L3);
            L4 = h*(derV(K3) + SunInf(K3));
        }
    }
    for (int i = 0 ; i < nObj ; i++){
        NewR[i] = sys[i].relR + (K1[i] + 2*K2[i] + 2*K3[i] + K4[i])/(double)6;
        NewV[i] = sys[i].relV + (L1[i] + 2*L2[i] + 2*L3[i] + L4[i])/(double)6;
    }
    calc_potential();
    for (int i = 0 ; i < nObj ; i++){
        sys[i].update(NewR[i], NewV[i], sys[i].relT+h);
    }
}
void extractExamplesForView(const TrackList<SiftFeature>& tracks,
                            const cv::Mat& F,
                            const CameraProperties& camera1,
                            const CameraProperties& camera2,
                            const std::string& image_format,
                            const std::string& view,
                            int time,
                            const std::vector<double>& scales,
                            const std::vector<double>& angles) {
  // March along epipolar line.
  DistortedEpipolarRasterizer rasterizer(camera2, F);
  rasterizer.init();

  cv::Mat K1(camera1.matrix());
  cv::Mat K1_inv = K1.inv();

  TrackList<SiftFeature>::const_iterator track;
  for (track = tracks.begin(); track != tracks.end(); ++track) {
    Track<SiftFeature>::const_iterator iter = track->find(time);
    CHECK(iter != track->end()) << "Track does not contain the current frame";

    const SiftFeature& feature = iter->second;
    cv::Point2d y1(feature.position.x, feature.position.y);

    // Undo intrinsics, undistort, and re-apply intrinsics.
    cv::Point2d x1 = affineTransformImagePoint(y1, K1_inv);
    x1 = undistort(x1, camera1.distort_w);
    x1 = affineTransformImagePoint(x1, K1);

    // Extract the pixels of the epipolar line.
    std::vector<cv::Point> line;
    rasterizer.compute(x1, line);

    // Load first image.
    cv::Mat image;
    std::string image_file = makeImageFilename(image_format, view, time);
    bool ok = readGrayImage(image_file, image);
    CHECK(ok) << "Could not load image";

    std::deque<std::deque<SiftFeature> > features;
    extractFeaturesAlongLine(line, image, scales, angles, features);
  }
}
Exemple #19
0
ECIES::ECIES (OCTETSTR& M, ECPubKey& pk) {
	OCTETSTR P1, P2; // These are 0

	ECPrivKey u (pk.dp);
	V = ECPubKey(u);

	F2M z = ECSVDP_DH (pk.dp, u.s, pk.W);
	OCTETSTR Z = FE2OSP (z);
	OCTETSTR K = KDF2_SURDOC (Z, 32, P1); // 256 bits
	OCTETSTR K1 (16); // 128 bit symmetric encryption key
	OCTETSTR K2 (16); // 128 bit MAC key
	for (int j=0; j<K1.size();j++) {
		K1[j] = K[j];
	}
	for (int k=0; k<K2.size();k++) {
		K2[k] = K[k+K1.size()];
	}
	C = AES_CBC_IV0_Encrypt (K1, M);

	T = MAC1 (K2, C||P2);
}
//\fn Eigen::Vector3d ExtrinsicParam::undistortPoint(Eigen::Vector3d distortedPoint);
///\brief This function undistorts a distorted point on the image coordinates. After calling this function, the first value of the returned vector should be multiplied by fx and added to cx and the second value should be multiplied by fy and added to cy.
///\param distortedPoint the distorted point to undistort.
///\return The value of the undistorted point in the image coordinates.
Eigen::Vector3d ExtrinsicParam::undistortPoint(Eigen::Vector3d distortedPoint)
{
  Eigen::Vector3d res;
  
  // Convert the camera matrix to an OpenCV matrix
  cv::Mat K1(3,3,CV_64F);
  K1.at<double>(0,0) = K(0,0);
  K1.at<double>(0,1) = K(0,1);
  K1.at<double>(0,2) = K(0,2);
  K1.at<double>(1,0) = K(1,0);
  K1.at<double>(1,1) = K(1,1);
  K1.at<double>(1,2) = K(1,2);
  K1.at<double>(2,0) = K(2,0);
  K1.at<double>(2,1) = K(2,1);
  K1.at<double>(2,2) = K(2,2);

  // Convert the distortion vector to an OpenCV vector
  cv::Mat distCoeffs(5,1,CV_64F);
  distCoeffs.at<double>(0,0) = dist(0);
  distCoeffs.at<double>(1,0) = dist(1);
  distCoeffs.at<double>(2,0) = dist(2);
  distCoeffs.at<double>(3,0) = dist(3);
  distCoeffs.at<double>(4,0) = dist(4);

  // Convert the distorted point vector to an OpenCV vector
  cv::Mat src(1,1,CV_64FC2);
  src.at<double>(0,0) = distortedPoint(0);
  src.at<double>(0,1) = distortedPoint(1);
  cv::Mat dst;

  // Undistort the point
  cv::undistortPoints(src, dst, K1, distCoeffs);

  // Fill the undistorted point vector and return it
  res(0) = dst.at<double>(0,0);
  res(1) = dst.at<double>(0,1);
  res(2) = 1.;
  return res;
}
Exemple #21
0
/*** contributions from the mirror image H0 ***/
static double
strikexH0 (MagComp component, const fault_params *fault, const magnetic_params *mag, double xi, double et, double qq, double y, double z)
{
	double val;
	double h = mag->dcurier;
	double qd = y * sd + (fault->fdepth - h) * cd;
	double K1_val = K1 (component, 1.0, xi, et, qq);
	double atan_xe_qr_val = atan_xe_qr (component, 1.0, xi, et, qq);
	double J1_val = J1 (component, 1.0, xi, et, qq);
	double M1_val = M1 (component, 1.0, xi, et, qq);
	double L1_val = L1 (component, 1.0, xi, et, qq);
	double M1y_val = M1y (component, 1.0, xi, et, qq);
	double M1z_val = M1z (component, 1.0, xi, et, qq);

	val = - (2.0 - alpha4) * K1_val
		- alpha1 * atan_xe_qr_val - alpha3 * J1_val
		- alpha3 * (qd * M1_val + (z - h) * L1_val * sd)
		- 2.0 * alpha4 * h * (M1_val * cd - L1_val * sd)
		- 4.0 * alpha1 * h * L1_val * sd
		+ 2.0 * alpha2 * h * ((qd + h * cd) * M1z_val - (z - 2.0 * h) * M1y_val * sd);

	return val;
}
Exemple #22
0
// Throws ECIES_Err if the tag is invalid
OCTETSTR ECIES::decrypt (ECPrivKey& sk) {
	OCTETSTR P1, P2; // These are 0

	F2M z = ECSVDP_DH (sk.dp, sk.s, V.W);
	OCTETSTR Z = FE2OSP (z);
	OCTETSTR K = KDF2_SURDOC (Z, 32, P1); // 256 bits

	OCTETSTR K1 (16); // 128 bit symmetric encryption key
	OCTETSTR K2 (16); // 128 bit MAC key
	for (int j=0; j<K1.size();j++) {
		K1[j] = K[j];
	}
	for (int k=0; k<K2.size();k++) {
		K2[k] = K[k+K1.size()];
	}
	OCTETSTR M = AES_CBC_IV0_Decrypt (K1, C);

	if (T != MAC1 (K2, C||P2)) {
		throw borzoiException ("ECIES: tag invalid");
	}

	return M;
}
Exemple #23
0
vector<SPACETYPE> RungeKutta4::Solve(vector<SPACETYPE> initialValue, TIMETYPE finalTime)
{
	// N is the number of spatial gridpoints
	int N = initialValue.size();

	if (_spatialSolver==NULL)
		return initialValue;

	//mSolution.push_back(initialValue);

 // vector<vector<complex<double> > > mSolution(_timeSteps);
  double time=0;

  double h = finalTime/(_timeSteps-1);

  vector<SPACETYPE> K1(N), K2(N), K3(N), K4(N), Temp(N), Unew(N);

  for(int i=1; i<_timeSteps; i++)
  {
    time+=h;


//K1

    K1 = _spatialSolver->GetSpatialSolution(initialValue);
    for(int j=0;j<N;j++)
    {
       K1[j] = h*K1[j];
    }

//K2
    for(int j=0;j<N;j++)
    {
       Temp[j] = initialValue[j] + K1[j]/2.0;
    }
    Temp = _spatialSolver->GetSpatialSolution(Temp);
    for(int j=0;j<N;j++)
    {
      K2[j] = h*Temp[j];
    }

//K3
    for(int j=0;j<N;j++)
    {
       Temp[j] = initialValue[j] + K2[j]/2.0;
    }
    Temp = _spatialSolver->GetSpatialSolution(Temp);
    for(int j=0;j<N;j++)
    {
      K3[j] = h*Temp[j];
    }

//K4
    for(int j=0;j<N;j++)
    {
      Temp[j] = initialValue[j] + K3[j];
    }
    Temp = _spatialSolver->GetSpatialSolution(Temp);
    for(int j=0;j<N;j++)
    {
      K4[j] = h*Temp[j];
    }

//New
    for(int j=0;j<N;j++)
    {
      Unew[j] = initialValue[j]+(1/6.0)*(K1[j]+2.0*(K2[j]+K3[j])+K4[j]);
    }
    //mSolution.push_back(Unew);
    initialValue = Unew;
  }
  return initialValue;

}
// Convert a Qt::Key_XXX code into the corresponding Linux keycode value.
// On failure, return -1.
static int convertKeyCode(int sym)
{
#define KK(x,y)  { Qt::Key_ ## x, KEY_ ## y }
#define K1(x)    KK(x,x)
    static const struct {
        int qt_sym;
        int keycode;
    } kConvert[] = {
        KK(Left, LEFT),
        KK(Right, RIGHT),
        KK(Up, UP),
        KK(Down, DOWN),
        K1(0),
        K1(1),
        K1(2),
        K1(3),
        K1(4),
        K1(5),
        K1(6),
        K1(7),
        K1(8),
        K1(9),
        K1(F1),
        K1(F2),
        K1(F3),
        K1(F4),
        K1(F5),
        K1(F6),
        K1(F7),
        K1(F8),
        K1(F9),
        K1(F10),
        K1(F11),
        K1(F12),
        K1(A),
        K1(B),
        K1(C),
        K1(D),
        K1(E),
        K1(F),
        K1(G),
        K1(H),
        K1(I),
        K1(J),
        K1(K),
        K1(L),
        K1(M),
        K1(N),
        K1(O),
        K1(P),
        K1(Q),
        K1(R),
        K1(S),
        K1(T),
        K1(U),
        K1(V),
        K1(W),
        K1(X),
        K1(Y),
        K1(Z),
        KK(Minus, MINUS),
        KK(Equal, EQUAL),
        KK(Backspace, BACKSPACE),
        KK(Home, HOME),
        KK(Escape, ESC),
        KK(Comma, COMMA),
        KK(Period,DOT),
        KK(Space, SPACE),
        KK(Slash, SLASH),
        KK(Return,ENTER),
        KK(Tab, TAB),
        KK(BracketLeft, LEFTBRACE),
        KK(BracketRight, RIGHTBRACE),
        KK(Backslash, BACKSLASH),
        KK(Semicolon, SEMICOLON),
        KK(Apostrophe, APOSTROPHE),
    };
    const size_t kConvertSize = sizeof(kConvert) / sizeof(kConvert[0]);
    size_t nn;
    for (nn = 0; nn < kConvertSize; ++nn) {
        if (sym == kConvert[nn].qt_sym) {
            return kConvert[nn].keycode;
        }
    }
    return -1;
}
Exemple #25
0
int test_string_cast_vector()
{
	int Error = 0;

	{
		glm::vec2 A1(1, 2);
		std::string A2 = glm::to_string(A1);
		Error += A2 != std::string("vec2(1.000000, 2.000000)") ? 1 : 0;
	
		glm::vec3 B1(1, 2, 3);
		std::string B2 = glm::to_string(B1);
		Error += B2 != std::string("vec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;

		glm::vec4 C1(1, 2, 3, 4);
		std::string C2 = glm::to_string(C1);
		Error += C2 != std::string("vec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
	
		glm::dvec2 J1(1, 2);
		std::string J2 = glm::to_string(J1);
		Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0;
	
		glm::dvec3 K1(1, 2, 3);
		std::string K2 = glm::to_string(K1);
		Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;
	
		glm::dvec4 L1(1, 2, 3, 4);
		std::string L2 = glm::to_string(L1);
		Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
	}

	{
		glm::bvec2 M1(false, true);
		std::string M2 = glm::to_string(M1);
		Error += M2 != std::string("bvec2(false, true)") ? 1 : 0;
	
		glm::bvec3 O1(false, true, false);
		std::string O2 = glm::to_string(O1);
		Error += O2 != std::string("bvec3(false, true, false)") ? 1 : 0;

		glm::bvec4 P1(false, true, false, true);
		std::string P2 = glm::to_string(P1);
		Error += P2 != std::string("bvec4(false, true, false, true)") ? 1 : 0;
	}

	{
		glm::ivec2 D1(1, 2);
		std::string D2 = glm::to_string(D1);
		Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0;
	
		glm::ivec3 E1(1, 2, 3);
		std::string E2 = glm::to_string(E1);
		Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0;
	
		glm::ivec4 F1(1, 2, 3, 4);
		std::string F2 = glm::to_string(F1);
		Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0;
	}

	{
		glm::i8vec2 D1(1, 2);
		std::string D2 = glm::to_string(D1);
		Error += D2 != std::string("i8vec2(1, 2)") ? 1 : 0;
	
		glm::i8vec3 E1(1, 2, 3);
		std::string E2 = glm::to_string(E1);
		Error += E2 != std::string("i8vec3(1, 2, 3)") ? 1 : 0;
	
		glm::i8vec4 F1(1, 2, 3, 4);
		std::string F2 = glm::to_string(F1);
		Error += F2 != std::string("i8vec4(1, 2, 3, 4)") ? 1 : 0;
	}

	{
		glm::i16vec2 D1(1, 2);
		std::string D2 = glm::to_string(D1);
		Error += D2 != std::string("i16vec2(1, 2)") ? 1 : 0;
	
		glm::i16vec3 E1(1, 2, 3);
		std::string E2 = glm::to_string(E1);
		Error += E2 != std::string("i16vec3(1, 2, 3)") ? 1 : 0;
	
		glm::i16vec4 F1(1, 2, 3, 4);
		std::string F2 = glm::to_string(F1);
		Error += F2 != std::string("i16vec4(1, 2, 3, 4)") ? 1 : 0;
	}

	{
		glm::i64vec2 D1(1, 2);
		std::string D2 = glm::to_string(D1);
		Error += D2 != std::string("i64vec2(1, 2)") ? 1 : 0;
	
		glm::i64vec3 E1(1, 2, 3);
		std::string E2 = glm::to_string(E1);
		Error += E2 != std::string("i64vec3(1, 2, 3)") ? 1 : 0;
	
		glm::i64vec4 F1(1, 2, 3, 4);
		std::string F2 = glm::to_string(F1);
		Error += F2 != std::string("i64vec4(1, 2, 3, 4)") ? 1 : 0;
	}

	return Error;
}
Exemple #26
0
TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
{
    const int n_images = 34;

    const std::string folder =combine(datasets_repository_path, "calib-3_stereo_from_JY");

    std::vector<std::vector<cv::Point2d> > leftPoints(n_images);
    std::vector<std::vector<cv::Point2d> > rightPoints(n_images);
    std::vector<std::vector<cv::Point3d> > objectPoints(n_images);

    cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
    CV_Assert(fs_left.isOpened());
    for(int i = 0; i < n_images; ++i)
    fs_left[cv::format("image_%d", i )] >> leftPoints[i];
    fs_left.release();

    cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
    CV_Assert(fs_right.isOpened());
    for(int i = 0; i < n_images; ++i)
    fs_right[cv::format("image_%d", i )] >> rightPoints[i];
    fs_right.release();

    cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
    CV_Assert(fs_object.isOpened());
    for(int i = 0; i < n_images; ++i)
    fs_object[cv::format("image_%d", i )] >> objectPoints[i];
    fs_object.release();

    cv::Matx33d theR;
    cv::Vec3d theT;

    int flag = 0;
    flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
    flag |= cv::fisheye::CALIB_CHECK_COND;
    flag |= cv::fisheye::CALIB_FIX_SKEW;
    flag |= cv::fisheye::CALIB_FIX_INTRINSIC;

    cv::Matx33d K1 (561.195925927249,                0, 621.282400272412,
                                   0, 562.849402029712, 380.555455380889,
                                   0,                0,                1);

    cv::Matx33d K2 (560.395452535348,                0, 678.971652040359,
                                   0,  561.90171021422, 380.401340535339,
                                   0,                0,                1);

    cv::Vec4d D1 (-7.44253716539556e-05, -0.00702662033932424, 0.00737569823650885, -0.00342230256441771);
    cv::Vec4d D2 (-0.0130785435677431, 0.0284434505383497, -0.0360333869900506, 0.0144724062347222);

    cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
                    K1, D1, K2, D2, imageSize, theR, theT, flag,
                    cv::TermCriteria(3, 12, 0));

    cv::Matx33d R_correct(   0.9975587205950972,   0.06953016383322372, 0.006492709911733523,
                           -0.06956823121068059,    0.9975601387249519, 0.005833595226966235,
                          -0.006071257768382089, -0.006271040135405457, 0.9999619062167968);
    cv::Vec3d T_correct(-0.099402724724121, 0.00270812139265413, 0.00129330292472699);


    EXPECT_MAT_NEAR(theR, R_correct, 1e-10);
    EXPECT_MAT_NEAR(theT, T_correct, 1e-10);
}
Exemple #27
0
/*** main term ***/
static double
strikex0 (MagComp component, double xi, double et, double qq)
{
	return 2.0 * K1 (component, 1.0, xi, et, qq);
}
Exemple #28
0
void FindMaximum2::Fit(ColumnVector& Theta, int n_it)
{
   Tracer tr("FindMaximum2::Fit");
   enum State {Start, Restart, Continue, Interpolate, Extrapolate,
      Fail, Convergence};
   State TheState = Start;
   Real z,w,x,x2,g,l1,l2,l3,d1,d2=0,d3;
   ColumnVector Theta1, Theta2, Theta3;
   int np = Theta.Nrows();
   ColumnVector H1(np), H3, HP(np), K, K1(np);
   bool oorg, conv;
   int counter = 0;
   Theta1 = Theta; HP = 0.0; g = 0.0;

   // This is really a set of gotos and labels, but they do not work
   // correctly in AT&T C++ and Sun 4.01 C++.

   for(;;)
   {
      switch (TheState)
      {
      case Start:
	 tr.ReName("FindMaximum2::Fit/Start");
	 Value(Theta1, true, l1, oorg);
	 if (oorg) Throw(ProgramException("invalid starting value\n"));

      case Restart:
	 tr.ReName("FindMaximum2::Fit/ReStart");
	 conv = NextPoint(H1, d1);
	 if (conv) { TheState = Convergence; break; }
	 if (counter++ > n_it) { TheState = Fail; break; }

	 z = 1.0 / sqrt(d1);
	 H3 = H1 * z; K = (H3 - HP) * g; HP = H3;
	 g = 0.0;                     // de-activate to use curved projection
	 if (g==0.0) K1 = 0.0; else K1 = K * 0.2 + K1 * 0.6;
	 // (K - K1) * alpha + K1 * (1 - alpha)
	 //     = K * alpha + K1 * (1 - 2 * alpha)
	 K = K1 * d1; g = z;

      case Continue:
	 tr.ReName("FindMaximum2::Fit/Continue");
	 Theta2 = Theta1 + H1 + K;
	 Value(Theta2, false, l2, oorg);
	 if (counter++ > n_it) { TheState = Fail; break; }
	 if (oorg)
	 {
	    H1 *= 0.5; K *= 0.25; d1 *= 0.5; g *= 2.0;
	    TheState =  Continue; break;
	 }
	 d2 = LastDerivative(H1 + K * 2.0);

      case Interpolate:
	 tr.ReName("FindMaximum2::Fit/Interpolate");
	 z = d1 + d2 - 3.0 * (l2 - l1);
	 w = z * z - d1 * d2;
	 if (w < 0.0) { TheState = Extrapolate; break; }
	 w = z + sqrt(w);
	 if (1.5 * w + d1 < 0.0)
	    { TheState = Extrapolate; break; }
	 if (d2 > 0.0 && l2 > l1 && w > 0.0)
	    { TheState = Extrapolate; break; }
	 x = d1 / (w + d1); x2 = x * x; g /= x;
	 Theta3 = Theta1 + H1 * x + K * x2;
	 Value(Theta3, true, l3, oorg);
	 if (counter++ > n_it) { TheState = Fail; break; }
	 if (oorg)
	 {
	    if (x <= 1.0)
	       { x *= 0.5; x2 = x*x; g *= 2.0; d1 *= x; H1 *= x; K *= x2; }
	    else
	    {
	       x = 0.5 * (x-1.0); x2 = x*x; Theta1 = Theta2;
	       H1 = (H1 + K * 2.0) * x;
	       K *= x2; g = 0.0; d1 = x * d2; l1 = l2;
	    }
	    TheState = Continue; break;
	 }

	 if (l3 >= l1 && l3 >= l2)
	    { Theta1 = Theta3; l1 = l3; TheState =  Restart; break; }

	 d3 = LastDerivative(H1 + K * 2.0);
	 if (l1 > l2)
	    { H1 *= x; K *= x2; Theta2 = Theta3; d1 *= x; d2 = d3*x; }
	 else
	 {
	    Theta1 = Theta2; Theta2 = Theta3;
	    x -= 1.0; x2 = x*x; g = 0.0; H1 = (H1 + K * 2.0) * x;
	    K *= x2; l1 = l2; l2 = l3; d1 = x*d2; d2 = x*d3;
	    if (d1 <= 0.0) { TheState = Start; break; }
	 }
	 TheState =  Interpolate; break;

      case Extrapolate:
	 tr.ReName("FindMaximum2::Fit/Extrapolate");
	 Theta1 = Theta2; g = 0.0; K *= 4.0; H1 = (H1 * 2.0 + K);
	 d1 = 2.0 * d2; l1 = l2;
	 TheState = Continue; break;

      case Fail:
	 Throw(ConvergenceException(Theta));

      case Convergence:
	 Theta = Theta1; return;
      }
   }
}
Exemple #29
0
ValueType
StringKernel<ValueType>::
operator()(const std::string& x, const std::string& y) const
{
  const value_type& g=gap_;
  value_type g2=g*g;
  typedef boost::multi_array<value_type,2> dp_type;
#if 1

  dp_type K0(boost::extents[x.size()+1][y.size()+1]);
  dp_type G0(boost::extents[x.size()+1][y.size()+1]);
  std::vector<value_type> K1(y.size()+1);
  std::vector<value_type> G1(y.size()+1);

  K0[0][0]=G0[0][0]=1.0;
  for (uint i=1; i!=x.size()+1; ++i) {
    K0[i][0]=1.0;
    G0[i][0]=G0[i-1][0]*g;
  }
  for (uint j=1; j!=y.size()+1; ++j) {
    K0[0][j]=1.0;
    G0[0][j]=G0[0][j-1]*g;
  }

  for (uint i=1; i!=x.size()+1; ++i) {
    K1[0]=G1[0]=0.0;
    for (uint j=1; j!=y.size()+1; ++j) {
      K1[j] = K1[j-1];
      G1[j] = G1[j-1]*g;
      if (x[i-1]==y[j-1]) {
	K1[j] += G0[i-1][j-1]*g2;
	G1[j] += G0[i-1][j-1]*g2;
      }
      K0[i][j] = K0[i-1][j] + K1[j];
      G0[i][j] = G0[i-1][j]*g + G1[j];
    }
  }

  return K0[x.size()][y.size()];

#else

  dp_type K0(boost::extents[x.size()+1][y.size()+1]);
  dp_type G0(boost::extents[x.size()+1][y.size()+1]);
  dp_type K1(boost::extents[x.size()+1][y.size()+1]);
  dp_type G1(boost::extents[x.size()+1][y.size()+1]);

  K0[0][0]=G0[0][0]=1.0;
  for (uint i=1; i!=x.size()+1; ++i) {
    K0[i][0]=1.0;
    G0[i][0]=G0[i-1][0]*g;
  }
  for (uint j=1; j!=y.size()+1; ++j) {
    K0[0][j]=1.0;
    G0[0][j]=G0[0][j-1]*g;
  }

  for (uint i=1; i!=x.size()+1; ++i) {
    K1[i][0]=G1[i][0]=0.0;
    for (uint j=1; j!=y.size()+1; ++j) {
      K1[i][j] = K1[i][j-1];
      G1[i][j] = G1[i][j-1]*g;
      if (x[i-1]==y[j-1]) {
	K1[i][j] += G0[i-1][j-1]*g2;
	G1[i][j] += G0[i-1][j-1]*g2;
      }
      K0[i][j] = K0[i-1][j] + K1[i][j];
      G0[i][j] = G0[i-1][j]*g + G1[i][j];
    }
  }

  return K0[x.size()][y.size()];
#endif
}
Exemple #30
0
void rk4(
    Vector &Xcurrent,
    const double t,
    const double stepSize,
    Vector &Xnext,
    orbiterEquationsOfMotion &derivatives )
{
    const double h = stepSize;
    const int numberOfElements = Xcurrent.size( );

    // Evaluate K1 step in RK4 algorithm.
    Vector dXdtCurrent( numberOfElements );
    Vector K1( numberOfElements );
    derivatives( t, Xcurrent, dXdtCurrent );
    for( int i = 0; i < numberOfElements; i++ )
    {
        K1[ i ] = h * dXdtCurrent[ i ];
    }

    // Evaluate K2 step in RK4 algorithm.
    Vector dXdt_K2( numberOfElements );
    Vector K2( numberOfElements );
    const double t_K2 = t + 0.5 * h;
    Vector X_K2( numberOfElements );
    for( int i = 0; i < numberOfElements; i++ )
    {
        X_K2[ i ] = Xcurrent[ i ] + 0.5 * K1[ i ];
    }
    derivatives( t_K2, X_K2, dXdt_K2 );
    for( int i = 0; i < numberOfElements; i++ )
    {
        K2[ i ] = h * dXdt_K2[ i ];
    }

    // Evaluate K3 step in RK4 algorithm.
    Vector dXdt_K3( numberOfElements );
    Vector K3( numberOfElements );
    const double t_K3 = t + 0.5 * h;
    Vector X_K3( numberOfElements );
    for( int i = 0; i < numberOfElements; i++ )
    {
        X_K3[ i ] = Xcurrent[ i ] + 0.5 * K2[ i ];
    }
    derivatives( t_K3, X_K3, dXdt_K3 );
    for( int i = 0; i < numberOfElements; i++ )
    {
        K3[ i ] = h * dXdt_K3[ i ];
    }

    // Evaluate K4 step in RK4 algorithm.
    Vector dXdt_K4( numberOfElements );
    Vector K4( numberOfElements );
    const double t_K4 = t + h;
    Vector X_K4( numberOfElements );
    for( int i = 0; i < numberOfElements; i++ )
    {
        X_K4[ i ] = Xcurrent[ i ] + K3[ i ];
    }
    derivatives( t_K4, X_K4, dXdt_K4 );
    for( int i = 0; i < numberOfElements; i++ )
    {
        K4[ i ] = h * dXdt_K4[ i ];
    }

    // Final step, evaluate the weighted summation.
    for( int i = 0; i < numberOfElements; i++ )
    {
        Xnext[ i ] = Xcurrent[ i ]
                        + ( 1.0 / 6.0 ) * K1[ i ]
                        + ( 1.0 / 3.0 ) * K2[ i ]
                        + ( 1.0 / 3.0 ) * K3[ i ]
                        + ( 1.0 / 6.0 ) * K4[ i ];
    }
}