bool Mda::write64(const char* path) const { if (QString(path).endsWith(".txt")) { return d->write_to_text_file(path, ' '); } if (QString(path).endsWith(".csv")) { return d->write_to_text_file(path, ','); } FILE* output_file = fopen(path, "wb"); if (!output_file) { printf("Warning: Unable to open mda file for writing: %s\n", path); return false; } MDAIO_HEADER H; H.data_type = MDAIO_TYPE_FLOAT64; H.num_bytes_per_entry = 4; for (int i = 0; i < MDAIO_MAX_DIMS; i++) H.dims[i] = 1; for (int i = 0; i < MDA_MAX_DIMS; i++) H.dims[i] = d->dims(i); H.num_dims = d->determine_num_dims(N1(), N2(), N3(), N4(), N5(), N6()); mda_write_header(&H, output_file); mda_write_float64((double*)d->constData(), &H, d->totalSize(), output_file); d->incrementBytesWrittenCounter(d->totalSize() * H.num_bytes_per_entry); fclose(output_file); return true; }
int main(){ TTableContext Context; // create scheme Schema AnimalS; AnimalS.Add(TPair<TStr,TAttrType>("Animal", atStr)); AnimalS.Add(TPair<TStr,TAttrType>("Size", atStr)); AnimalS.Add(TPair<TStr,TAttrType>("Location", atStr)); AnimalS.Add(TPair<TStr,TAttrType>("Number", atInt)); TIntV RelevantCols; RelevantCols.Add(0); RelevantCols.Add(1); RelevantCols.Add(2); // create table PTable T = TTable::LoadSS("Animals", AnimalS, "tests/animals.txt", Context, RelevantCols); //PTable T = TTable::LoadSS("Animals", AnimalS, "animals.txt"); T->Unique("Animal"); TTable Ts = *T; // did we fix problem with copy-c'tor ? //PTable Ts = TTable::LoadSS("Animals_s", AnimalS, "../../testfiles/animals.txt", RelevantCols); //Ts->Unique(AnimalUnique); // test Select // create predicate tree: find all animals that are big and african or medium and Australian TPredicate::TAtomicPredicate A1(atStr, true, EQ, "Location", "", 0, 0, "Africa"); TPredicate::TPredicateNode N1(A1); // Location == "Africa" TPredicate::TAtomicPredicate A2(atStr, true, EQ, "Size", "", 0, 0, "big"); TPredicate::TPredicateNode N2(A2); // Size == "big" TPredicate::TPredicateNode N3(AND); N3.AddLeftChild(&N1); N3.AddRightChild(&N2); TPredicate::TAtomicPredicate A4(atStr, true, EQ, "Location", "", 0, 0, "Australia"); TPredicate::TPredicateNode N4(A4); TPredicate::TAtomicPredicate A5(atStr, true, EQ, "Size", "", 0, 0, "medium"); TPredicate::TPredicateNode N5(A5); TPredicate::TPredicateNode N6(AND); N6.AddLeftChild(&N4); N6.AddRightChild(&N5); TPredicate::TPredicateNode N7(OR); N7.AddLeftChild(&N3); N7.AddRightChild(&N6); TPredicate Pred(&N7); TIntV SelectedRows; Ts.Select(Pred, SelectedRows); TStrV GroupBy; GroupBy.Add("Location"); T->Group(GroupBy, "LocationGroup"); GroupBy.Add("Size"); T->Group(GroupBy, "LocationSizeGroup"); T->Count("LocationCount", "Location"); PTable Tj = T->Join("Location", Ts, "Location"); TStrV UniqueAnimals; UniqueAnimals.Add("Animals_1.Animal"); UniqueAnimals.Add("Animals_2.Animal"); Tj->Unique(UniqueAnimals, false); //print table T->SaveSS("tests/animals_out_T.txt"); Ts.SaveSS("tests/animals_out_Ts.txt"); Tj->SaveSS("tests/animals_out_Tj.txt"); return 0; }
double* Mda::dataPtr(bigint i1, bigint i2, bigint i3, bigint i4, bigint i5, bigint i6) { const bigint N12 = N1() * N2(); const bigint N13 = N12 * N3(); const bigint N14 = N13 * N4(); const bigint N15 = N14 * N5(); return d->data() + (i1 + N1() * i2 + N12 * i3 + N13 * i4 + N14 * i5 + N15 * i6); }
bool Mda::reshape(bigint N1b, bigint N2b, bigint N3b, bigint N4b, bigint N5b, bigint N6b) { if (N1b * N2b * N3b * N4b * N5b * N6b != this->totalSize()) { qWarning() << "Unable to reshape Mda, wrong total size"; qWarning() << N1b << N2b << N3b << N4b << N5b << N6b; qWarning() << N1() << N2() << N3() << N4() << N5() << N6(); return false; } d->setDims(N1b, N2b, N3b, N4b, N5b, N6b); return true; }
int main() { Nef_polyhedron N1(Plane_3( 1, 0, 0,-1),Nef_polyhedron::INCLUDED); Nef_polyhedron N2(Plane_3(-1, 0, 0,-1),Nef_polyhedron::INCLUDED); Nef_polyhedron N3(Plane_3( 0, 1, 0,-1),Nef_polyhedron::INCLUDED); Nef_polyhedron N4(Plane_3( 0,-1, 0,-1),Nef_polyhedron::INCLUDED); Nef_polyhedron N5(Plane_3( 0, 0, 1,-1),Nef_polyhedron::INCLUDED); Nef_polyhedron N6(Plane_3( 0, 0,-1,-1),Nef_polyhedron::INCLUDED); Nef_polyhedron I1(!N1+!N2); Nef_polyhedron I2(N3-!N4); Nef_polyhedron I3(N5^N6); Nef_polyhedron Cube1(I2 *!I1); Cube1 *= !I3; Nef_polyhedron Cube2 = N1 * N2 * N3 * N4 * N5 * N6; CGAL_assertion (Cube1 == Cube2); return 0; }
bool Mda::write16ui(const QString& path) const { FILE* output_file = fopen(path.toLatin1().data(), "wb"); if (!output_file) { printf("Warning: Unable to open mda file for writing: %s\n", path.toLatin1().data()); return false; } MDAIO_HEADER H; H.data_type = MDAIO_TYPE_UINT16; H.num_bytes_per_entry = 2; for (int i = 0; i < MDAIO_MAX_DIMS; i++) H.dims[i] = 1; for (int i = 0; i < MDA_MAX_DIMS; i++) H.dims[i] = d->dims(i); H.num_dims = d->determine_num_dims(N1(), N2(), N3(), N4(), N5(), N6()); mda_write_header(&H, output_file); mda_write_float64((double*)d->constData(), &H, d->totalSize(), output_file); d->incrementBytesWrittenCounter(d->totalSize() * H.num_bytes_per_entry); fclose(output_file); return true; }
int main() { Nef_polyhedron N0; Nef_polyhedron N1(Nef_polyhedron::EMPTY); Nef_polyhedron N2(Nef_polyhedron::COMPLETE); Nef_polyhedron N3(Plane_3( 1, 2, 5,-1)); Nef_polyhedron N4(Plane_3( 1, 2, 5,-1), Nef_polyhedron::INCLUDED); Nef_polyhedron N5(Plane_3( 1, 2, 5,-1), Nef_polyhedron::EXCLUDED); CGAL_assertion(N0 == N1); CGAL_assertion(N3 == N4); CGAL_assertion(N0 != N2); CGAL_assertion(N3 != N5); CGAL_assertion(N4 >= N5); CGAL_assertion(N5 <= N4); CGAL_assertion(N4 > N5); CGAL_assertion(N5 < N4); N5 = N5.closure(); CGAL_assertion(N4 >= N5); CGAL_assertion(N4 <= N5); return 0; }
int Mda::ndims() const { return d->determine_num_dims(N1(), N2(), N3(), N4(), N5(), N6()); }