Include-what-you-use
IWYU
is a static analysis tool that helps find missing and unused #include statements in C / C++ source files.
Like any tool, IWYU makes mistakes, so make changes incrementally and be ready to rollback edits.
CMake has IWYU support that is enabled in project CMakeLists.txt by including this stanza BEFORE any targets are defined:
Upon building the project, CMake will run IWYU on all source files.
IWYU emits messages as each source file is built, if there are any issues.
IWYU does not emit messages by default when there are no issues.
For numerical plots, it can be important to label the ticks of axes extrema (minimum or maximum).
For example, to clearly show the edges of simulated data axes.
This can be easily done in Python Matplotlib or in Matlab.
This assumes the typical case that the axes values are numeric.
In this example, the y-axis ticks show the endpoints of the y-data range: -3.375 and 27.0.
The data are in general non-monotonic, so we sort ticks before resetting them.
Python: Matplotlib does not require sorting the ticks.
frommatplotlib.pyplotimport figure, show
importnumpyasnp# synthetic datax = np.arange(-1.5, 3.25, 0.25)
y = x**3fg = figure()
ax = fg.gca()
ax.plot(x, y)
# label min and max ticksyticks = np.append(ax.get_yticks(), [y.min(), y.max()])
ax.set_yticks(yticks)
show()
Matlab: requires sorting the ticks before resetting them.
% synthetic datax = -1.5:0.25:3.0;
y = x.^3;
fg = figure;
ax = axes(fg);
plot(ax, x, y)
% label min and max ticksyticks = sort([ax.YTick, min(y), max(y)]);
ax.YTick = yticks;
We provide a CMake project of recent C++ language standad examples, including
C++20 modules.
The
C++ standard compiler support table
is not always up to date.
That’s why we make CMake projects to test compiler support of newer language standard features.
In Python Matplotlib or Matlab, making a plot with log-scaled (instead of default linear-scaled) axes can use the functions like “loglog()”, “semilogx()”, or “semilogy()”.
Here we show the more general object-oriented syntax for each of a 2-D line “plot()” and 2-D pseudocolor “pcolor()” and then set the axes scale properties.
We arbitrarily use log abscissa scale and linear ordinate scale, but the same syntax applies to other combinations.
importnumpyasnpfrommatplotlib.pyplotimport figure, show
x = np.logspace(0, 10, 100)
y = np.log(x)**2fg = figure()
ax = fg.gca()
ax.plot(x, y)
ax.set_xscale('log')
ax.set_xlabel('x')
ax.set_ylabel('y')
show()
pseudocolor pcolormesh(): observe the stretching of the ticks along the y-axis.
In some cases it’s helpful to set the axis limits manually to avoid whitespace past the last data point.
importnumpyasnpfrommatplotlib.pyplotimport figure, show
d = np.random.rand(10, 10)
x = np.linspace(1, 10, d.shape[0])
y = np.logspace(0, 1, d.shape[1])
fg = figure()
ax = fg.gca()
ax.pcolormesh(x, y, d)
ax.set_yscale('log')
ax.set_ylim(y[0], y[-1])
ax.set_xlabel('x')
ax.set_ylabel('y')
show()
pseudocolor pcolor(): observe the stretching of the ticks along the y-axis.
In some cases it’s helpful to set the axis limits manually to avoid whitespace past the last data point.
d = rand(10, 10);
x = linspace(1, 10, size(d, 1));
y = logspace(0, 1, size(d, 2));
fg = figure();
ax = axes(fg);
pcolor(ax, x, y, d);
ax.YScale = 'log';
xlabel(ax, 'x');
ylabel(ax, 'y');
If one suspects a website has been compromised, don’t use a standard web browser to access the site as there could be zero-day malware on the site.
Consider Terminal programs that don’t have JavaScript enabled like
curl
or
lynx
if necessary to browse the site, preferably from a VM or other isolated computing resource.
These programs are also not immune from security vulnerabilities.
DNSViz
helps visualize the DNS chain.
Keep in mind DNS and nameserver updates can take minutes to hours to propagate.
macOS:
dscacheutil -q host -a name host.invalid
Linux / macOS / WSL:
dig +trace host.invalid
If the DNS entries seem valid, consider that the web hosting server (that sends the HTML files to browser) may be compromised.
Matlab Compiler
compiles existing .m Matlab script to run as an executable on another PC without Matlab.
Matlab Compiler Runtime
MCR
is used on computers that don’t have Matlab to run the compiled Matlab code.
Caveats:
Matlab Compiler does not in general speedup Matlab code execution
in general, compiled binaries might be disassembled to reverse-engineer the underlying code
MCR version on each computer running the executable must match the Matlab version of the compiling Matlab, and the compiling computer must have the same operating system as the MCR running computers.
Compiling computer: ensure Matlab Compiler is installed:
assert(license('test', 'compiler') == 1)
Example program “mymcc.m”:
functionY =mymcc()X = 0:0.01:2*3.14;
Y = sin(X);
plot(X,Y)
title('Test of MCR')
xlabel('x')
ylabel('y')
disp('I ran an MCR program!')
end
Compile “.m” file in Matlab:
mcc -m -v mymcc.m
Run compiled Matlab program:
./run_mymcc.sh mymcc
I ran an MCR program!
and show a Matlab plot window showing a sine wave.
Close the plot window to end the execution of your program.
GNU Octave does not currently have the ability to compile “.m” files.
Octave
mkoctfile
is to distribute C / C++ code that calls Octave functions–and ABI-compatible Octave must be installed on the user computers
There can be substantial speed boosts from Intel compilers with Intel CPUs.
Intel oneAPI gives advanced debuggers and performance measurements.
Intel oneMKL can give a significant speed boost to ABI-compatible compilers for certain math operations.
For Windows, use the oneAPI Command Prompt.
Otherwise, specify environment variables CC, CXX, FC to indicate desired compilers
via script:
Native
virtualization
has a “guest” OS with the same CPU architecture as the “host” physical CPU.
Non-native emulation generally runs slower than native virtualization.
Non-native virtualization means a host computer (such as Apple Silicon) can emulate any supported CPU architecture.
Apple Silicon is ARM64, but with virtualization such as UTM / QEMU the Apple Silicon CPU can emulate ARM32, x86_64, MIPS, RISC-V, PowerPC, and more within the container.
QEMU emulator is available on
Homebrew for Apple Silicon
and can emulate a different CPU architecture or run native architecture at nearly full performance.
UTM
is a containerized emulation based off of QEMU for iOS and macOS–like QEMU, the same CPU architecture is virtualized at near full performance, while non-native virtualization is emulated with slower performance.
When creating a new virtual machine in UTM, the first questions include whether the VM will be virtualized (native) or emulated (non-native) and the CPU architecture.
UTM works with native virtualized Windows 11 for ARM, Linux, and emulates many architectures, even old PowerPC macOS guest images.
VirtualBox is an open-source native virtualization application that generally targets x86_64 CPUs.
VirtualBox “Developer Preview” for Apple Silicon is available from the
Nightly Builds
as “macOS/ARM64 BETA”.
The Oracle developer notes that the VirtualBox Apple Silicon beta is
not yet ready for production use.
Commercial paid Apple Silicon virtualization: these native virtualization applications are not open-source. They run native virtual machines on Apple Silicon including Windows 11 ARM.
Parallels is paid-only software
VMWare Fusion is paid software, but has a no-cost personal-use license for home users.
HDF5 is a popular data container format, a filesystem within a file.
Many programs supporting HDF5 like Matlab can read and plot data.
It is useful to have a standalone simple data browser like HDFview.
HDFview
from the HDF Group can read HDF5, NetCDF4, and FITS.
HDFview enables editing (writing) as well as reading HDF5.
One can simply download the HDFview binaries, or use package managers: