A least-squares method of interpreting magnetic anomalies caused by two-dimensional structures