--- /dev/null
+New: add LinearAlgebra::distributed::BlockVector::norm_sqr() and
+LinearAlgebra::distributed::Vector::norm_sqr() that return square of the l2 norm.
+<br>
+(Denis Davydov, 2017/12/21)
*/
virtual real_type l2_norm() const override;
+ /**
+ * Return square of the l<sub>2</sub> norm of the vector.
+ */
+ real_type norm_sqr() const;
+
/**
* Return the maximum norm of the vector (i.e., the maximum absolute value
* among all entries and among all processors).
template <typename Number>
inline
typename BlockVector<Number>::real_type
- BlockVector<Number>::l2_norm () const
+ BlockVector<Number>::norm_sqr () const
{
Assert (this->n_blocks() > 0, ExcEmptyObject());
local_result += this->block(i).norm_sqr_local();
if (this->block(0).partitioner->n_mpi_processes() > 1)
- return std::sqrt(Utilities::MPI::sum (local_result,
- this->block(0).partitioner->get_communicator()));
+ return Utilities::MPI::sum (local_result,
+ this->block(0).partitioner->get_communicator());
else
- return std::sqrt(local_result);
+ return local_result;
+ }
+
+
+
+ template <typename Number>
+ inline
+ typename BlockVector<Number>::real_type
+ BlockVector<Number>::l2_norm () const
+ {
+ return std::sqrt(norm_sqr());
}
*/
virtual real_type l2_norm() const override;
+ /**
+ * Return square of the l<sub>2</sub> norm of the vector.
+ */
+ real_type norm_sqr() const;
+
/**
* Return the maximum norm of the vector (i.e., the maximum absolute value
* among all entries and among all processors).
template <typename Number>
typename Vector<Number>::real_type
- Vector<Number>::l2_norm () const
+ Vector<Number>::norm_sqr () const
{
real_type local_result = norm_sqr_local();
if (partitioner->n_mpi_processes() > 1)
- return std::sqrt(Utilities::MPI::sum(local_result,
- partitioner->get_mpi_communicator()));
+ return Utilities::MPI::sum(local_result,
+ partitioner->get_mpi_communicator());
else
- return std::sqrt(local_result);
+ return local_result;
+ }
+
+
+
+ template <typename Number>
+ typename Vector<Number>::real_type
+ Vector<Number>::l2_norm () const
+ {
+ return std::sqrt(norm_sqr());
}