namespace rogueviz { namespace embeddings { enum class fmt { hyperb, poincare, bhyper }; string format_names[3] = { "hyperboloid trailing", "Poincare", "hyperboloid leading" }; fmt coord_format; struct coord_embedding : public untiled_embedding { vector coords; hyperpoint as_hyperpoint(int id) override { return coords[id]; } virtual string name() { return "coordinates: " + format_names[(int) coord_format]; } ld zero_distance(int id) { return hdist0(coords[id]); } ld distance(int i, int j) { return precise_hdist(coords[i], coords[j]); } void save(fhstream& f) override { int i = 0; for(auto& co: coords) { println(f, vdata[i++].name); switch(coord_format) { case fmt::hyperb: for(int i=0; i (); int N = isize(vdata); pe->coords.resize(N); if(fn == "-") { for(int i=0; icoords[i] = current->as_hyperpoint(i); } return enable_embedding(pe); } fhstream f(fn, "rt"); if(!f.f) return file_error(fn); for(int i=0; i(f); if(s == "") throw hr_exception("data failure"); int id = rogueviz::labeler.at(s); auto& co = pe->coords[id]; switch(coord_format) { case fmt::hyperb: for(int i=0; i(f); break; case fmt::bhyper: co[MDIM-1] = scan(f); for(int i=0; i(f); break; case fmt::poincare: hyperpoint h1; for(int i=0; i(f); co = perspective_to_space(h1, 1); break; } co = normalize(co); } enable_embedding(pe); } int a_coord = arg::add3("-el-coord", [] { arg::shift(); read_coord(arg::args()); }) + arg::add3("-ec-hyperb", [] { coord_format = fmt::hyperb; }) + arg::add3("-ec-bhyper", [] { coord_format = fmt::bhyper; }) + arg::add3("-ec-poincare", [] { coord_format = fmt::poincare; }); } }