I'm a newbie too. In the answer above, it talks about decoding the DDS into a bitmap, and the re-encoding it once the rows have been reversed.
For your reference, here is a code to reverse the row order of a bitmap. Note that the image has 4 channels, hence the magic number 4. Where Pixels is a vector of unsigned char, of size width*height*4:
// Reverse row ...
The simplest option for loading DDS files is probably to use the open source library that Microsoft provide - https://github.com/Microsoft/DirectXTK. That doesn't include functionality to turn them upside down when loading them though.
If you really want to do it manually, then take a look at https://docs.microsoft.com/en-us/windows/win32/direct3ddds/dx-...
It's just a math library, so as long as it doesn't interact with the actual D3D API, then you can in theory use any math library you wish.
Things to watch out for might include row-major vs column-major matrix conventions, -1..1 or 0..1 NDC Z conventions, etc, but otherwise choice of math library should be relatively constraint-free.