void testFuncCallOp() { qDebug() << "Testing GpxFile::operator()"; GpxFile gpx("data/test1.gpx"); assert(gpx(0).elevation() == 50); assert(gpx(1).elevation() == 55); assert(gpx(2).elevation() == 60); qDebug() << "GpxFile::operator() tests passed"; }
int main() { GpxFile gpx("data/quandry.gpx"); qDebug() << "Total distance: " << meter2mile(gpx.length()) << " miles"; qDebug() << "Total duration: " << formatDuration(gpx.duration()); qDebug() << "Max speed: " << meterPerSecond2MilePerHour(gpx.maxSpeed()) << " mph"; qDebug() << "Average speed: " << meterPerSecond2MilePerHour(gpx.averageSpeed()) << " mph"; qDebug() << "\nNumber of segments: " << gpx.segmentCount(); for (int i=0; i<gpx.segmentCount(); ++i) { qDebug() << "Segment " << (i+1) << " has " << gpx[i].pointCount() << " points, " "length " << meter2mile(gpx[i].length()) << " miles, " "duration " << formatDuration(gpx[i].duration()) << "max speed of " << meterPerSecond2MilePerHour(gpx[i].maxSpeed()) << " mph, " "and average speed of " << meterPerSecond2MilePerHour(gpx[i].averageSpeed()) << " mph"; } testBounds(); testFuncCallOp(); testMerge(); qDebug() << "All tests passed."; return 0; }
void testMerge() { qDebug() << "Testing track merge"; QStringList tom = QStringList() << "ACTIVE LOG #2" << "ACTIVE LOG #3" << "ACTIVE LOG #4"; GpxFile gpx("data/test2.gpx"); assert(gpx.segmentCount() == 3); assert(gpx[0].name() == "ACTIVE LOG #2"); assert(gpx[1].name() == "ACTIVE LOG #3"); int ptCount = gpx.pointCount(); gpx.mergeTracksByName(tom); assert(gpx.segmentCount() == 1); assert(gpx[0].name() == "ACTIVE LOG #2"); assert(gpx.pointCount() == ptCount); qDebug() << "Track merge tests passed"; QString tmp; gpx.toXml(tmp); qDebug() << tmp; }
void ConstructA_CG2(const mesh& Mesh, FullMatrix& A) { const int NumPhysElems = Mesh.get_NumPhysElems(); const int NumBndNodes = Mesh.get_SubNumBndNodes(); const int Asize = Mesh.get_SubNumPhysNodes(); assert_eq(Asize,A.get_NumRows()); assert_eq(Asize,A.get_NumCols()); dTensor1 A1(6); dTensor1 A2(6); dTensor1 A3(6); dTensor1 A4(6); dTensor1 A5(6); dTensor1 A6(6); A1.set(1, -oneninth ); A1.set(2, 4.0*oneninth ); A1.set(3, -oneninth ); A1.set(4, 4.0*oneninth ); A1.set(5, 4.0*oneninth ); A1.set(6, -oneninth ); A2.set(1, -onethird ); A2.set(2, 0.0 ); A2.set(3, onethird ); A2.set(4, -4.0*onethird ); A2.set(5, 4.0*onethird ); A2.set(6, 0.0 ); A3.set(1, -onethird ); A3.set(2, -4.0*onethird ); A3.set(3, 0.0 ); A3.set(4, 0.0 ); A3.set(5, 4.0*onethird ); A3.set(6, onethird ); A4.set(1, 4.0 ); A4.set(2, -4.0 ); A4.set(3, 0.0 ); A4.set(4, -4.0 ); A4.set(5, 4.0 ); A4.set(6, 0.0 ); A5.set(1, 2.0 ); A5.set(2, -4.0 ); A5.set(3, 2.0 ); A5.set(4, 0.0 ); A5.set(5, 0.0 ); A5.set(6, 0.0 ); A6.set(1, 2.0 ); A6.set(2, 0.0 ); A6.set(3, 0.0 ); A6.set(4, -4.0 ); A6.set(5, 0.0 ); A6.set(6, 2.0 ); dTensor2 spts(3,2); spts.set(1,1, 1.0/3.0 ); spts.set(1,2, -1.0/6.0 ); spts.set(2,1, -1.0/6.0 ); spts.set(2,2, -1.0/6.0 ); spts.set(3,1, -1.0/6.0 ); spts.set(3,2, 1.0/3.0 ); dTensor1 wgts(3); wgts.set(1, 1.0/6.0 ); wgts.set(2, 1.0/6.0 ); wgts.set(3, 1.0/6.0 ); // Loop over all elements in the mesh for (int i=1; i<=NumPhysElems; i++) { // Information for element i iTensor1 tt(6); for (int k=1; k<=6; k++) { tt.set(k, Mesh.get_node_subs(i,k) ); } // Evaluate gradients of the Lagrange polynomials on Gauss quadrature points dTensor2 gpx(6,3); dTensor2 gpy(6,3); for (int m=1; m<=3; m++) { double xi = spts.get(m,1); double eta = spts.get(m,2); for (int k=1; k<=6; k++) { double gp_xi = A2.get(k) + 2.0*A5.get(k)*xi + A4.get(k)*eta; double gp_eta = A3.get(k) + A4.get(k)*xi + 2.0*A6.get(k)*eta; gpx.set(k,m, Mesh.get_jmat(i,1,1)*gp_xi + Mesh.get_jmat(i,1,2)*gp_eta ); gpy.set(k,m, Mesh.get_jmat(i,2,1)*gp_xi + Mesh.get_jmat(i,2,2)*gp_eta ); } } // Entries of the stiffness matrix A double Area = Mesh.get_area_prim(i); for (int j=1; j<=6; j++) for (int k=1; k<=6; k++) { double tmp = A.get(tt.get(j),tt.get(k)); for (int m=1; m<=3; m++) { tmp = tmp + 2.0*Area*wgts.get(m)*(gpx.get(j,m)*gpx.get(k,m)+gpy.get(j,m)*gpy.get(k,m)); } A.set(tt.get(j),tt.get(k), tmp ); } } // Replace boundary node equations by Dirichlet boundary condition enforcement for (int i=1; i<=NumBndNodes; i++) { const int j=Mesh.get_sub_bnd_node(i); for (int k=1; k<=A.get_NumCols(); k++) { A.set(j,k, 0.0 ); } for (int k=1; k<=A.get_NumRows(); k++) { A.set(k,j, 0.0 ); } A.set(j,j, 1.0 ); } // Get sparse structure representation A.Sparsify(); }
void V800export::export_sessions(QList<QString> sessions, unsigned char mode) { QSettings settings; QString default_dir = settings.value(tr("default_dir")).toString(); for(int sessions_iter = 0; sessions_iter < sessions.length(); sessions_iter++) { QStringList filters; filters << QString(tr("%1_*")).arg(sessions[sessions_iter]); QDir filter_dir(default_dir); filter_dir.setNameFilters(filters); filter_dir.setFilter(QDir::Dirs); int multi_sessions_iter; QStringList multi_sessions = filter_dir.entryList(); for(multi_sessions_iter = 0; multi_sessions_iter < multi_sessions.length(); multi_sessions_iter++) { if(!make_bipolar_names(multi_sessions[multi_sessions_iter])) { emit export_session_error(sessions[sessions_iter], RENAME_ERROR); continue; } QString session_info(QString(tr("%1/%2/v2-users-0000000-training-sessions-%3")).arg(default_dir).arg(multi_sessions[multi_sessions_iter]).arg(multi_sessions[multi_sessions_iter])); polar::v2::TrainingSession parser(session_info); qDebug("Parser: %s", session_info.toUtf8().constData()); parser.setTcxOption(polar::v2::TrainingSession::ForceTcxUTC, true); if(!parser.parse()) emit export_session_error(sessions[sessions_iter], PARSE_ERROR); if(mode & TCX_EXPORT) { QString tcx(QString(tr("%1/%2.tcx")).arg(default_dir).arg(multi_sessions[multi_sessions_iter])); if(!parser.writeTCX(tcx)) emit export_session_error(sessions[sessions_iter], TCX_ERROR); } if(mode & HRM_EXPORT) { QString hrm(QString(tr("%1/%2")).arg(default_dir).arg(multi_sessions[multi_sessions_iter])); QStringList hrm_out = parser.writeHRM(hrm); if(hrm_out.length() < 1) emit export_session_error(sessions[sessions_iter], HRM_ERROR); } if(mode & GPX_EXPORT) { QString gpx(QString(tr("%1/%2.gpx")).arg(default_dir).arg(multi_sessions[multi_sessions_iter])); if(!parser.writeGPX(gpx)) emit export_session_error(sessions[sessions_iter], GPX_ERROR); } QDir(QString(tr("%1/%2")).arg(default_dir).arg(multi_sessions[multi_sessions_iter])).removeRecursively(); } emit export_session_done(sessions_iter, sessions.length()); } emit export_sessions_done(); }