Skip to content

Commit a0a30d6

Browse files
committed
wip9
1 parent f8ce5ba commit a0a30d6

File tree

4 files changed

+98
-119
lines changed

4 files changed

+98
-119
lines changed

app/gui/project-external-source-editor.cpp

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -385,202 +385,202 @@ bool show_random_distribution_input(random_source& src) noexcept
385385
switch (src.distribution) {
386386
case distribution_type::uniform_int: {
387387
if (old_current != current_item) {
388-
src.a32 = 0;
389-
src.b32 = 100;
388+
src.ints[0] = 0;
389+
src.ints[1] = 100;
390390
}
391391

392-
int a = src.a32;
393-
int b = src.b32;
392+
int a = src.ints[0];
393+
int b = src.ints[1];
394394

395395
if (ImGui::InputInt("a", &a)) {
396396
up++;
397397

398398
if (a < b)
399-
src.a32 = a;
399+
src.ints[0] = a;
400400
else
401-
src.b32 = a + 1;
401+
src.ints[1] = a + 1;
402402
}
403403

404404
if (ImGui::InputInt("b", &b)) {
405405
up++;
406406

407407
if (a < b)
408-
src.b32 = b;
408+
src.ints[1] = b;
409409
else
410-
src.a32 = b - 1;
410+
src.ints[0] = b - 1;
411411
}
412412
} break;
413413

414414
case distribution_type::uniform_real: {
415415
if (old_current != current_item) {
416-
src.a = 0.0;
417-
src.b = 1.0;
416+
src.reals[0] = 0.0;
417+
src.reals[1] = 1.0;
418418
}
419419

420-
auto a = src.a;
421-
auto b = src.b;
420+
auto a = src.reals[0];
421+
auto b = src.reals[1];
422422

423423
if (ImGui::InputDouble("a", &a)) {
424424
++up;
425425
if (a < b)
426-
src.a = a;
426+
src.reals[0] = a;
427427
else
428-
src.b = a + 1;
428+
src.reals[1] = a + 1;
429429
}
430430

431431
if (ImGui::InputDouble("b", &b)) {
432432
++up;
433433
if (a < b)
434-
src.a = a;
434+
src.reals[0] = a;
435435
else
436-
src.b = a + 1;
436+
src.reals[1] = a + 1;
437437
}
438438
} break;
439439

440440
case distribution_type::bernouilli:
441441
if (old_current != current_item) {
442-
src.p = 0.5;
442+
src.reals[0] = 0.5;
443443
}
444-
if (ImGui::InputDouble("p", &src.p))
444+
if (ImGui::InputDouble("p", &src.reals[0]))
445445
++up;
446446
break;
447447

448448
case distribution_type::binomial:
449449
if (old_current != current_item) {
450-
src.p = 0.5;
451-
src.t32 = 1;
450+
src.reals[0] = 0.5;
451+
src.ints[0] = 1;
452452
}
453-
if (ImGui::InputDouble("p", &src.p))
453+
if (ImGui::InputDouble("p", &src.reals[0]))
454454
++up;
455-
if (ImGui::InputInt("t", &src.t32))
455+
if (ImGui::InputInt("t", &src.ints[0]))
456456
++up;
457457
break;
458458

459459
case distribution_type::negative_binomial:
460460
if (old_current != current_item) {
461-
src.p = 0.5;
462-
src.t32 = 1;
461+
src.reals[0] = 0.5;
462+
src.ints[0] = 1;
463463
}
464-
if (ImGui::InputDouble("p", &src.p))
464+
if (ImGui::InputDouble("p", &src.reals[0]))
465465
++up;
466-
if (ImGui::InputInt("t", &src.k32))
466+
if (ImGui::InputInt("t", &src.ints[0]))
467467
++up;
468468
break;
469469

470470
case distribution_type::geometric:
471471
if (old_current != current_item) {
472-
src.p = 0.5;
472+
src.reals[0] = 0.5;
473473
}
474-
if (ImGui::InputDouble("p", &src.p))
474+
if (ImGui::InputDouble("p", &src.reals[0]))
475475
++up;
476476
break;
477477

478478
case distribution_type::poisson:
479479
if (old_current != current_item) {
480-
src.mean = 0.5;
480+
src.reals[0] = 0.5;
481481
}
482-
if (ImGui::InputDouble("mean", &src.mean))
482+
if (ImGui::InputDouble("mean", &src.reals[0]))
483483
++up;
484484
break;
485485

486486
case distribution_type::exponential:
487487
if (old_current != current_item) {
488-
src.lambda = 1.0;
488+
src.reals[0] = 1.0;
489489
}
490-
if (ImGui::InputDouble("lambda", &src.lambda))
490+
if (ImGui::InputDouble("lambda", &src.reals[0]))
491491
++up;
492492
break;
493493

494494
case distribution_type::gamma:
495495
if (old_current != current_item) {
496-
src.alpha = 1.0;
497-
src.beta = 1.0;
496+
src.reals[0] = 1.0;
497+
src.reals[1] = 1.0;
498498
}
499-
if (ImGui::InputDouble("alpha", &src.alpha))
499+
if (ImGui::InputDouble("alpha", &src.reals[0]))
500500
++up;
501-
if (ImGui::InputDouble("beta", &src.beta))
501+
if (ImGui::InputDouble("beta", &src.reals[1]))
502502
++up;
503503
break;
504504

505505
case distribution_type::weibull:
506506
if (old_current != current_item) {
507-
src.a = 1.0;
508-
src.b = 1.0;
507+
src.reals[0] = 1.0;
508+
src.reals[1] = 1.0;
509509
}
510-
if (ImGui::InputDouble("a", &src.a))
510+
if (ImGui::InputDouble("a", &src.reals[0]))
511511
++up;
512-
if (ImGui::InputDouble("b", &src.b))
512+
if (ImGui::InputDouble("b", &src.reals[1]))
513513
++up;
514514
break;
515515

516516
case distribution_type::exterme_value:
517517
if (old_current != current_item) {
518-
src.a = 1.0;
519-
src.b = 0.0;
518+
src.reals[0] = 1.0;
519+
src.reals[1] = 0.0;
520520
}
521-
if (ImGui::InputDouble("a", &src.a))
521+
if (ImGui::InputDouble("a", &src.reals[0]))
522522
++up;
523-
if (ImGui::InputDouble("b", &src.b))
523+
if (ImGui::InputDouble("b", &src.reals[1]))
524524
++up;
525525
break;
526526

527527
case distribution_type::normal:
528528
if (old_current != current_item) {
529-
src.mean = 0.0;
530-
src.stddev = 1.0;
529+
src.reals[0] = 0.0;
530+
src.reals[1] = 1.0;
531531
}
532-
if (ImGui::InputDouble("mean", &src.mean))
532+
if (ImGui::InputDouble("mean", &src.reals[0]))
533533
++up;
534-
if (ImGui::InputDouble("stddev", &src.stddev))
534+
if (ImGui::InputDouble("stddev", &src.reals[1]))
535535
++up;
536536
break;
537537

538538
case distribution_type::lognormal:
539539
if (old_current != current_item) {
540-
src.m = 0.0;
541-
src.s = 1.0;
540+
src.reals[0] = 0.0;
541+
src.reals[1] = 1.0;
542542
}
543-
if (ImGui::InputDouble("m", &src.m))
543+
if (ImGui::InputDouble("m", &src.reals[0]))
544544
++up;
545-
if (ImGui::InputDouble("s", &src.s))
545+
if (ImGui::InputDouble("s", &src.reals[1]))
546546
++up;
547547
break;
548548

549549
case distribution_type::chi_squared:
550550
if (old_current != current_item) {
551-
src.n = 1.0;
551+
src.reals[0] = 1.0;
552552
}
553-
if (ImGui::InputDouble("n", &src.n))
553+
if (ImGui::InputDouble("n", &src.reals[0]))
554554
++up;
555555
break;
556556

557557
case distribution_type::cauchy:
558558
if (old_current != current_item) {
559-
src.a = 1.0;
560-
src.b = 0.0;
559+
src.reals[0] = 1.0;
560+
src.reals[1] = 0.0;
561561
}
562-
if (ImGui::InputDouble("a", &src.a))
562+
if (ImGui::InputDouble("a", &src.reals[0]))
563563
++up;
564-
if (ImGui::InputDouble("b", &src.b))
564+
if (ImGui::InputDouble("b", &src.reals[1]))
565565
++up;
566566
break;
567567

568568
case distribution_type::fisher_f:
569569
if (old_current != current_item) {
570-
src.m = 1.0;
571-
src.n = 1.0;
570+
src.reals[0] = 1.0;
571+
src.reals[1] = 1.0;
572572
}
573-
if (ImGui::InputDouble("m", &src.m))
573+
if (ImGui::InputDouble("m", &src.reals[0]))
574574
++up;
575-
if (ImGui::InputDouble("s", &src.n))
575+
if (ImGui::InputDouble("s", &src.reals[1]))
576576
++up;
577577
break;
578578

579579
case distribution_type::student_t:
580580
if (old_current != current_item) {
581-
src.n = 1.0;
581+
src.reals[0] = 1.0;
582582
}
583-
if (ImGui::InputDouble("n", &src.n))
583+
if (ImGui::InputDouble("n", &src.reals[0]))
584584
++up;
585585
break;
586586
}

lib/include/irritator/core.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,6 @@ class random_source
590590
std::array<real, 2> reals;
591591
std::array<i32, 2> ints;
592592

593-
double a = 0, b = 1, p = 0, mean = 0, lambda = 0, alpha = 0, beta = 0,
594-
stddev = 0, m = 0, s = 0, n = 0;
595-
int a32 = 0, b32 = 0, t32 = 0, k32 = 0;
596593
distribution_type distribution = distribution_type::uniform_real;
597594

598595
random_source() noexcept = default;

lib/src/archiver.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,8 @@ struct binary_archiver::impl {
402402
template<typename Stream>
403403
bool do_serialize_external_source(Stream& io, random_source& src) noexcept
404404
{
405-
return io(src.distribution) and io(src.a) and io(src.b) and
406-
io(src.p) and io(src.mean) and io(src.lambda) and
407-
io(src.alpha) and io(src.beta) and io(src.stddev) and
408-
io(src.m) and io(src.s) and io(src.n) and io(src.a32) and
409-
io(src.b32) and io(src.t32) and io(src.k32);
405+
return io(src.distribution) and io(src.reals[0]) and
406+
io(src.reals[1]) and io(src.ints[0]) and io(src.ints[1]);
410407
}
411408

412409
template<typename Stream>

0 commit comments

Comments
 (0)