Compressed Sensing: Mathematical Foundations, Implementation, and Advanced Optimization Techniques