A magnetic sensor provided with a magnetoresistive effect element capable
of stably maintaining a direction of magnetization in a magnetic domain
of a free layer. The magnetic sensor includes a magnetoresistive effect
element provided with narrow zonal portions including a pinned layer and
a free layer. Disposed below both ends of the free layer are bias magnet
films composed of a permanent magnet that applies to the free layer a
bias magnetic field in a predetermined direction and an initializing coil
that is disposed in the vicinity of the free layer and applies to the
free layer a magnetic field having the direction same as that of the bias
magnetic field by being energized under a predetermined condition.
Further, magnetizing the bias magnet films and fixing the direction of
magnetization of the pinned layer are performed by a magnetic field
formed by a magnet array configured such that plural permanent magnets
are arranged on a lattice point of a tetragonal lattice and a polarity of
a magnet pole of each permanent magnet is different from a polarity of
the other adjacent magnet pole spaced by the shortest route.