To calculate yaw ,pitch and roll correctly from your 3X3 flattened matrix i need following details
There are a lot of choices we need to make in mathematics, for example,
Left or right handed coordinate systems.
Vector shown as row or column.
Direction of x,y and z coordinates.
Euler angle order
Direction of positive angles
Choice of basis for bivectors