C++Guns – RoboBlog blogging the bot

06.05.2020

C++ Guns: generate random bits - std C++ way

Filed under: Allgemein — Tags: — Thomas @ 05:05

I found only one std C++ way to generator random bool value: using std::bernoulli_distribution. It returns bool values and has a default constructor with probability p=0.5. So the generated boolen are "uniform" distributed.

This is perhaps the slowest variant. The internet is full of better ideas. Some use std C++ random classes but they all need some extra code to work. For example: cast int to bool, extract one bit from a 32bit integer value.

#include <random>

std::random_device rd;
std::mt19937 g(rd());
std::bernoulli_distribution dis_true_false;

if(dis_true_false(g)) {
   // heads
} else {
   // tails
}

25.02.2020

C++ Guns: Special Members

Filed under: Allgemein — Tags: — Thomas @ 11:02

Engineering Distinguished Speaker Series: Howard Hinnant

Make yourself pretty coloring

special_members

special_members.ods

19.02.2020

Graph - Goldberg-Tarjan - Preflow-push Visualisierung

Filed under: Allgemein — Thomas @ 15:02

preflowpush_visu

06.02.2020

C++ Guns: Style Guide

Filed under: Allgemein — Tags: — Thomas @ 19:02

Nicht zwingend HPC, ehr allgemein.


Strings werden mit std::string (pure C++) und/oder QString (Qt) dargestellt. Der C-String (char*) wird nicht mehr benutzt.

Das Konzept des C-Strings ist, die einzelnen Zeichen aneinander zu reihen und das Ende des Strings durch ein besonders ausgezeichnetes Zeichen darstellten: NULL. Das NULL Zeichen nennt man auch Sentinel. Dieses Prinzip ist auch 2020 Fehlerquelle #1 in Software.

In C++ werden Strings durch eine Aneinanderreihung von Zeichen dargestellt und zusätzlich die Länge des Strings separat gespeichert. Hierfür wird die Klasse std::string benutzt, welche intern 8-Byte Zeichen benutzt. Für GUI Anwendungen wird die Klasse QString verwendet, welche 16-Byte Zeichen benutzt. Um auch "Sonderzeichen" wie Umlaute oder EUR immer korrekt darzustellen.

Das Konzept des Sentinels ist nicht schlecht, es wurde sogar in C++17 standardisiert. Damit war es möglich in C++20 "Ranges" einzuführen. Eine grundsätzlich neue Technologie in der std C++ Welt.


17.01.2020

Gewölbekeller

Filed under: Allgemein — Thomas @ 10:01

Da wo jetzt das Haus steht, war früher eine Scheune mit Keller. Der Gewölbekeller blieb erhalten und modert jetzt vor sich hin.

Das ist eine gute Gelegenheit das neue Langzeit Temperatur und Luftfeuchte Messgerät auszuprobieren.

erstemessung

Interpretation der Messung: Es ist dauerhaft kurz vor Nebelbildung :D

Aber warum schwankt die Luftfeuchte so und die Temperatur bleibt konstant? Es gibt zwar zwei Belüftungsrohre, aber die ragen nur so aus dem Boden heraus. Da bildet sich kein Durchzug. Auch wenn am 16.01.2020 ein schöner Frühlingstag war (im Januar), hat das die Temperatur im Keller überhaupt nicht beeinflusst.

Der alte Keller wird kaum gegen die Bodenfeuchtigkeit geschützt sein. Aber ob und wie diese sich innerhalb eines Tages ändert... gute Frage. Undichte Abwasserrohre sollten da auch keine sein, das würde man auch riechen. Ob die Sonne die obere Schicht vom Boden erwärmt und austrocknet und dann zeitversetzt die Feuchtigkeit aus dem Keller hoch wandert?

Wir werden es niemals erfahren, denn ich habe einen kleinen Ventilator in das Abluftrohr installiert. Der pustet jetzt fröhlich vor sich hin, der Stromverbrauch wird auch aufgenommen. Und wenn man die Nase an die Abluft hält, kommt einem gewaltiger Mief entgegen. Es bilden sich auch Wassertropfen im Rohr. Also feuchte Luft kommt da ganz sicher raus.

Hier der Plot vom ersten Tag.

zweitemessung_1

Diesmal bleibt die Luftfeuchte konstant. Das Wetter war am ersten Tag nicht so ganz frühlingshaft und es hat auch mal geregnet. Es bleibt abzuwarten wie sich das die nächsten Tage entwickelt.
(Das Messintervall von 1min auf 5min hochstellen ergibt bessere Plots).

Gnuplot script zum erstellen des Plots

set xdata time
set timefmt "%Y/%m/%d %H:%M:%S"
set format x '%H:%M'
set title "Messung Gewoelbekeller 15.01.2020 - 17.01.2020"
set xlabel "Tageszeit"
set ylabel "Temperatur"
set y2label "Luftfeuchte"
set yrange [ 6.00000 : 9.00000 ]
set y2range [ 90.0000 : 95.0000 ]
set grid
set y2tics auto
plot "erstemessung.csv" using 2:4 with lines title "rH%" axis x1y2, "" using 2:5 with lines title "Temp C", "" using 2:6 with lines title "Taupunkt C"

gewoelbekeller

05.01.2020

Rauchmelder Mars Alkaline 9V

Filed under: Allgemein — Thomas @ 13:01

Nach genau ein Jahr und einer Woche fingen die Rauchmelder wieder an zu piepen. Verbaut waren Mars Alkaline 9V Batterien (grau, schwarz mit roten Streifen). Billig in der Anschaffung, aber dafür landen jedes Jahr 5 Stück im Altbattarien Behälter. Und wie geht es von da aus weiter? Werden die Batterien wieder zerlegt, oder landen sie auf der Deponie oder gar im Ausland? Batterien enthalten Schwermetalle und sind damit Sondermüll!

Laut Internet halten nur Lithium Batterien mehrere Jahre. Mit 1.2Ah Kapazität sollen 10 Jahre erreicht werden. Diese kosten zwar ca. 8Eur statt ca. 1.5Eur, sind damit 5 mal so teuer. Das Geld wäre nach 5 Jahren wieder drin. Nicht zu vergessen den ersparten Ärger mit ständig piependen Rauchmelder, die investierte Zeit neue Batterien zu kaufen, auszutauschen, und auch die alten wieder weg zu bringen.

Über die Kapazität von Alkaline 9V Batterien findet man keine eindeutige Aussage. Das schwankt nicht nur von Hersteller zu Hersteller, auch Lagerzeit und vor allem Entladestrom haben einen großen Einfluss. Man liest öfter den Wert 400mAh. So ein Rauchmelder verbraucht extrem wenig Strom (weit kleiner 1mA ?). Ich würde mal behaupten, die Selbstentladungsrate eine Batterie ist höher.

Dennoch werde ich den Versuch starte die Restkapazität von 3 Batterien zu bestimmen. Sie wurden alle zeitgleich gekauft und haben alle 1 Jahr im Rauchmelder verbracht. Der kleinste vom Ladegerät einstellbare Entladestrom beträgt 100mA. Mit drei parallel geschalteten Batterien sind das ca. 33mA pro Batterie.

entladecurve_3x_9V

Die Entladung hat 15 Stunden gedauert und es wurde eine Kapazität von 1500mAh entnommen. WOW und das bei angeblich leeren Batterien?! Das macht 500mAh pro 9V Block. Das ist für mich eine volle Batterie ... tolle Verschwendung. Vielleicht sollte ich die Rauchmelder gleich mit entsorgen und gescheite kaufen.

Es gibt übriges eine Rauchmelder­pflicht seit Dezember 2014, auch für Bestandsbauten! Dabei sind die Bewohner/Mieter für die Wartung der Melder zuständig, sofern der Eigentümer nicht diese Pflicht über­nimm.

[1] https://www.test.de/Rauchmelderpflicht-Welche-Vorschriften-in-Ihrem-Bundesland-gelten-4485955-0/

25.12.2019

36C3

Filed under: Allgemein — Thomas @ 21:12

Lecture: The Ultimate Acorn Archimedes talk
https://media.ccc.de/v/36c3-10703-the_ultimate_acorn_archimedes_talk

This talk will cover everything about the Acorn Archimedes, a British computer first released in 1987 and (slightly) famous for being the genesis of the original ARM processor.


Lecture: Energiespeicher von heute für die Energie von morgen
https://media.ccc.de/v/36c3-11119-energiespeicher_von_heute_fur_die_energie_von_morgen

Wir verlassen uns in unserem Alltag permanent auf die Verfügbarkeit von elektrischer Energie. Aber wenn wir vom dauerhaften Betrieb von Kraftwerke, die fossile Energieträger verbrennen, wie stellen wir die Versorgung sicher, wenn nachts kein Wind weht?
Elektrolyse oder Pumpspeicherkraftwerk? Superkondensatoren oder mechanische Speicher? Was geht heute überhaupt schon?


Lecture: phyphox: Using smartphone sensors for physics experiments
https://media.ccc.de/v/36c3-11195-phyphox_using_smartphone_sensors_for_physics_experiments

Modern smartphones offer a whole range of sensors like magnetometers, accelerometers or gyroscopes. The open source app "phyphox", developed at the RWTH Aachen University, repurposes these sensors as measuring instruments in physics education.


Lecture: How to Break PDFs
https://media.ccc.de/v/36c3-10832-how_to_break_pdfs

PDF is the most widely used standard for office documents. Supported by many desktop applications, email gateways and web services solutions, are used in all sectors, including government, business and private fields. For protecting sensitive information, PDFs can be encrypted and digitally signed. Assumed to be secure for 15 years, our talk reveals how to break PDF Encryption and how to break PDF Signatures. We elaborated novel attacks leading to critical vulnerabilities in all PDF viewers, most notably in Adobe, Foxit, and Okular. As a result, an attacker can retrieve the plaintext of encrypted PDFs without knowing the password and manipulate the content of digitally signed PDFs arbitrarily while a victim is unable to detect this.


Lecture: The Large Hadron Collider Infrastructure Talk
https://media.ccc.de/v/36c3-10760-the_large_hadron_collider_infrastructure_talk
Sehr interessant!

The Large Hadron Collider (LHC) is the biggest particle accelerator on Earth. It was built to study matter in more detail than ever before and prove physical theories like the Standard Model of Particle Physics. This talk will focus on the engineering aspects of LHC. How was it built? What makes it tick? Which technologies are needed to create a such powerful machine? This talk will take you on a journey to explore how the most complex machine ever built by humans works.


Lecture: Server Infrastructure for Global Rebellion
https://media.ccc.de/v/36c3-11008-server_infrastructure_for_global_rebellion

In this talk Julian will outline his work as sysadmin, systems and security architect for the climate and environmental defense movement Extinction Rebellion. Responsible for 30 server deployments in 11 months, including a community hub spanning dozens of national teams (some of which operate in extremely hostile conditions), he will show why community-owned free and open source infrastructure is mission-critical for the growth, success and safety of global civil disobedience movements.


Lecture: Climate Modelling
https://media.ccc.de/v/36c3-10896-climate_modelling

When climate activists say you should listen to the science they usually
refer to reports by the Intergovernmental Panel on Climate Change (IPCC). The IPCC is an Intergovernmental organization (IGO) providing an objective summary of scienctific results regarding climate change, its impacts and its reasons. The simulation of future climate is one
fundamental pillar within climate research. But what is behind it? How does the science sector look like? How do we gain these insights, what does it mean?


Lecture: How (not) to build autonomous robots
https://mirror.selfnet.de/CCC//congress/2019/h264-hd/36c3-10601-eng-How_not_to_build_autonomous_robots.mp4
Jo

Over the past 2 years we've been building delivery robots - at first thought to be autonomous. We slowly came to the realization that it's not something we could easily do; but only after a few accidents, fires and pr disasters.


Lecture: Intel Management Engine deep dive
https://media.ccc.de/v/36c3-10694-intel_management_engine_deep_dive

Reverse engineering a system on a chip from sparse documentation and binaries, developing an emulator from it and gathering the knowledge needed to develop a replacement for one of the more controversial binary blobs in the modern PC.


Lecture: Mathematical diseases in climate models and how to cure them
https://media.ccc.de/v/36c3-11155-mathematical_diseases_in_climate_models_and_how_to_cure_them

Making climate predictions is extremely difficult because climate models cannot simulate every cloud particle in the atmosphere and every wave in the ocean, and the model has no idea what humans will do in the future. I will discuss how we are using the Julia programming language and GPUs in our attempt to build a fast and user-friendly climate model, and improve the accuracy of climate predictions by learning the small-scale physics from observations.


Lecture: (Post-Quantum) Isogeny Cryptography
https://media.ccc.de/v/36c3-10543-post-quantum_isogeny_cryptography

There are countless post-quantum buzzwords to list: lattices, codes, multivariate polynomial systems, supersingular elliptic curve isogenies. We cannot possibly explain in one hour what each of those mean, but we will do our best to give the audience an idea about why elliptic curves and isogenies are awesome for building strong cryptosystems.


Lecture: Uncover, Understand, Own - Regaining Control Over Your AMD CPU
https://media.ccc.de/v/36c3-10942-uncover_understand_own_-_regaining_control_over_your_amd_cpu

The AMD Platform Security Processor (PSP) is a dedicated ARM CPU inside your AMD processor and runs undocumented, proprietary firmware provided by AMD.


Lecture: The KGB Hack: 30 Years Later
https://media.ccc.de/v/36c3-11031-the_kgb_hack_30_years_later

This spring marked the 30th anniversary of the public uncovering of the so-called KGB Hack, bringing with it a number of new articles remembering the event and forging bridges to the present.


Lecture: Offene Sensordaten für Jedermann - Ein Citizen Science Projekt basierend auf Open Source und Open Hardware
https://media.ccc.de/v/36c3-10862-offene_sensordaten_fur_jedermann_-_ein_citizen_science_projekt_basierend_auf_open_source_und_open_hardware

Der Talk soll die Geschichte der senseBox von Beginn bis jetzt wiedergeben. Dabei möchte ich vor allem auf unsere Arbeit im Bereich Open Source, Open Data, Open Hardware und Open Educational Resources eingehen. Die Motivation von Teilnehmern des senseBox Projekts möchte ich basierend auf einer Nutzerstudie kurz wiedergeben. Außerdem möchte ich auf aktuelle Probleme sowie technische Hürden und die Genauigkeit der Daten eingehen. Zu guter Letzt gebe ich einen kurzen Ausblick in die Zukunft des Projekts.


Lecture: An ultrashort history of ultrafast imaging
https://media.ccc.de/v/36c3-10902-an_ultrashort_history_of_ultrafast_imaging

Did you ever wonder what happens in the time period it takes light to cross the diameter of your hair? This is the femtosecond, a millionth of a billionth of a second. It is the time scale of electron and nuclear motion, and therefore the most fundamental processes in atomic and molecular physics, chemistry and biology start here. In order to take movies with femtosecond time resolution, we need ultrafast cameras – flashes of light that act faster than any camera shutter ever could. And imaging ultrafast motion is only the first step: We aim to control dynamics on the femtosecond time scale, ultimately driving chemical reactions with light.


Lecture: On the insecure nature of turbine control systems in power generation
https://media.ccc.de/v/36c3-10689-on_the_insecure_nature_of_turbine_control_systems_in_power_generation

A deep dive into power generation process, industrial solutions and their security implications. Flavoured with vulnerabilities, penetration testing (security assessment) methodology and available remediation approaches.


Lecture: 36C3 Infrastructure Review
https://media.ccc.de/v/36c3-11235-36c3_infrastructure_review
Jedes Jahr gut

36C3 is run by teams of volunteers. In this event, they will provide some insight into the challenges they faced while building the GSM, DECT and IP networks, running video streams, or organizing ticket sales. All graphs will be pointing up and to the right.


Lecture: Getting software right with properties, generated tests, and proofs
https://media.ccc.de/v/36c3-10768-getting_software_right_with_properties_generated_tests_and_proofs

How do we write software that works - or rather, how do we ensure it's correct once it's written? We can just try it out and run it, and see if it works on a few examples. If the program was correct to begin with, that's great - but if it's not, we're going to miss bugs. Bugs that might crash our computer, make it vulnerable to attacks, stop the factory, endanger lives, or "just" leave us unsatisfied. This talk is about techniques every programmer can use to avoid large classes of bugs. You think about general properties of the things in your code, verify them through automatically generated tests, and (when it's particularly critical) proofs. This is a surprisingly fun and satisfying experience, and any programmer can do it. You need just a bit of high school math (which we'll refresh in the talk) to get started.


Lecture: Quantum Computing: Are we there yet?
https://media.ccc.de/v/36c3-11039-quantum_computing_are_we_there_yet

Five years ago I spoke about my work in quantum computing, building and running a tiny two qubit processor. A few weeks ago, Google announced a potentially groundbreaking result achieved with a 53 qubit quantum processor. I will therefore review the state of experimental quantum computing and discuss the progress we made in the last 5 years. I will explain quantum supremacy, surface code architecture and superconducting quantum processors and show which challenges we still have to overcome to build large scale quantum computers.


Lecture: Grow your own planet
https://media.ccc.de/v/36c3-10607-grow_your_own_planet

This year the Nobel prize in physics was awarded to three astronomers changing the understanding of the Universe and finding the first exoplanet. This is a good reason to dive into astronomy, numerics, and programming and to learn how modern astronomy creates the pictures and models of the reality we observe in the night sky.
Let’s find out together how we can simulate the Universe and grow new planets – computationally


Lecture: Nutzung öffentlicher Klimadaten
https://media.ccc.de/v/36c3-10571-nutzung_offentlicher_klimadaten

'In meiner Jugend war mehr Schnee!' oder 'Früher war es auch schon heiß!' könnte man so glauben, je nach Vehemenz des Ausrufs, oder man schaut halt nach.


Lecture: Linux on Open Source Hardware with Open Source chip design
https://media.ccc.de/v/36c3-10549-linux_on_open_source_hardware_with_open_source_chip_design

Want to run Linux on open hardware? This talk will explore Open Source Hardware projects capable of that task, and explore how RISC-V and free software FPGA projects can be leveraged to create libre systems.


Lecture: Verkehrswende selber hacken

Der Talk wird eine wilde Fahrt, vorbei an umfallenden Rollern, etwas Kunst mit Sharing-Daten, einer Shoppingtour aus Recherchegründen auf asiatischen Großhandelsplattformen, Sicherheitslücken in Fahrradschlössern, welche einen deutschen Bikesharer dazu bringen, seine 6000 Räder weltweit wieder einzusammeln, der Analyse von risikokapitalgetriebenen Sharingsystemen bis hin zum Gegenentwurf: Wie angewandte Lobbyarbeit für mehr offene Mobilitätsdaten aussieht. Und wie man es selbst in die Hand nehmen kann.


Lecture: Aufbau eines Sensornetzes für die Messung von Stickstoffdioxid

Ausgehend von den behördlichen Messnetz für Stickoxide soll der Aufbau einer preisgünstigen Open Source Messstation für Stickstoffdioxid, inklusive Kalibrierung und der behandlung von Störenden einflüssen behandelt werden. Zusätzlich soll eine Webanwendung vorgestellt werden welche die Daten aus einem Messnetz der NO2-Messstationen sammelt, auf Karten visualisiert und somit dem Citizen Science Ansatz Rechnung trägt.


Lecture: Wandel im Braunkohlerevier: Lithium-Ionen-Batterierecycling

Weltweit verlaufen die Entwicklungstrends des Markthochlaufs der Elektromobilität und die Weiterentwicklung relevanter Batteriefertigungs- und Recyclingtechnologien hoch dynamisch. Maßgebliche Faktoren für die Entstehung eines industriellen Batterierecycling-Marktes nehmen dabei erst langsam Gestalt an, der regulatorische Rahmen ist noch modellierbar. Zugleich ist der Technologiepfad Elektromobilität als eingeschlagen zu begreifen: Die Vorgaben des Klimaschutzplans der Bundes-regierung zur CO2-Reduktion begründen Umbrüche in der Automobilbranche, die mittelfristig zu steigenden Verkehrs-anteilen von Fahrzeugen mit rein elektrischem oder hybridem Antrieb an den PKW-Neuzulassungen führen werden.


Lecture: HAL - The Open-Source Hardware Analyzer

Since the Snowden revelations the fear of stealthy hardware manipulations is no longer regarded as far fetched.
This fear is also reflected in the massive discussions sparked by last year's Bloomberg allegations on a supposed hardware spy implant on Supermicro serverboards or the recent USA ban on Huawei telecommunication equipment.


Lecture: Understanding millions of gates

Reverse Engineering of integrated circuits is often seen as something only companies can do, as the equipment to image the chip is expensive, and the HR costs to hire enough reverse engineers to then understand the chip even more so. This talk gives a short introduction on the motivation behind understanding your own or someone else’s chip (as a chip manufacturing company), and why it might be important for the rest of us (not a chip manufacturing company). The focus is on understanding what millions of logical gates represent, rather than the physical aspect (delayering, imaging, image processing…), because everyone can do this at home. I will introduce some proposed countermeasures (like logic encryption) and explain if, how and why they fail.


Lecture: Science for future?
https://media.ccc.de/v/36c3-10991-science_for_future

This talk is to show the current state of the discussion on climate change and the necessary and possible changes from a scientific perpesctive. It is to give some typical relevant answers and to foster the resiliance against climate sceptic questioning. This is one of the main tasks the scientist for future are trying to tackle.

02.12.2019

C++ Guns - Graph - Dijkstra Beschleunigungstechniken

Filed under: Allgemein — Tags: — Thomas @ 09:12

Dijkstra - Single source shortest paths

Testgebeit DGM triangulation Rheinausschnitt mit 2.7 Millionen Punkte und 8.1 Millionen Kanten. Das Gebiet ist in Nord Süd Richtung lang gestreckt und in Ost West Richtung schmal. Es soll ein kürzester Path von einem Startpunkt auf der Ostrand hin zur Westrand gefunden werden. Der überwiegende Teil des Gebiets muss im Vergleich zur Luftlinie dabei nicht durchlaufen werden.

Standard Dijkstra
Die Standard Variante von Dijkstra berechnet vom Startknoten zu jedem anderen Knoten im Mesh den kürzesten Path.

Beschleunigungstechnik Early Termination
Sobald der Zielknoten als finish markiert wird, beendet der Algorithmus. Muss vom Start zum Ziel, wie in diesem Beispiel, nicht das komplette Gebiet durchlaufen werden, ergibt diese Technik eine Beschleunigung.

Beschleunigungstechnik Bidirectional Search
Es kann eine zweite Suche vom Zielknoten hin zum Startknoten auf dem transponierten Graph gestartet werden. Die beiden Dijkstra Instanzen werden nicht parallel, sondern abwechseln angestoßen und iterieren je ein mal. Sobald ein Knoten von einer Suchinstanz als finish markiert wird, welche in der anderen Suchinstanz schon als finish markiert worden ist, terminiert der Algorithmus.
Der ausgegebene Path muss nicht zwangsläufig der kürzeste Path von s nach t sein. Es ist möglich, dass es einen kürzeren Path über eine Kante gibt, welche in beiden Suchinstanzen auf gesehene, aber noch nicht finished Knoten zeigt.

Laufzeiten: GCC 8.2 -O2 -funroll-loops AMD FX-8350 Eight-Core Processor 4 GHz
Standard Dijkstra 2.79 sec
Early Termination 1.19 sec speedup 2.3
Bidirectional Search 0.925 sec speedup 3.0

rheinmodellumgriff3

Created with GIMP

Created with GIMP

Created with GIMP

Created with GIMP

19.11.2019

C++ Guns: ACPL proudly presents: ElapsedTimer

Filed under: Allgemein — Tags: — Thomas @ 13:11

ElapsedTimer: Measure amount of time with a monotonic clock.

https://sourceforge.net/p/acpl/code/ci/master/tree/acpl/Examples/ElapsedTimer/main.cpp

#include <iostream>
#include <thread>

#include <core/util/ElapsedTimer.hpp>

using namespace acpl;
using namespace std::chrono_literals;

int main() {
    std::cout << "Start timer and wait for 2 seconds ...\n";
    auto timer = ElapsedTimer::create();
    std::this_thread::sleep_for(2s);
    std::cout << timer.elapsed().count() << " seconds later\n";
    return 0;
}

15.11.2019

C++ Guns: P1935R0 A C++ Approach to Physical Units

Filed under: Allgemein — Tags: — Thomas @ 19:11

Unbedingt lesen!!!

P1935R0 A C++ Approach to Physical Units

« Newer PostsOlder Posts »

Powered by WordPress