Line data Source code
1 : /*
2 : * File: Norm.cpp
3 : * Author: chung
4 : *
5 : * Created on October 30, 2015, 5:32 PM
6 : */
7 :
8 : #include "Norm.h"
9 :
10 36 : Norm::Norm() : Function() {
11 36 : }
12 :
13 35 : Norm::~Norm() {
14 35 : }
15 :
16 82 : int Norm::callConj(Matrix& x, double& f_star) {
17 : double dNorm;
18 82 : int status = dualNorm(x, dNorm);
19 82 : if (ForBESUtils::STATUS_OK != status) {
20 0 : return status;
21 : }
22 82 : if (dNorm <= 1) {
23 81 : f_star = 0.0;
24 : } else {
25 1 : f_star = INFINITY;
26 : }
27 82 : return ForBESUtils::STATUS_OK;
28 : }
29 :
30 : //LCOV_EXCL_START
31 : int Norm::dualNorm(Matrix& x, double& norm) {
32 : /*
33 : * Method dualNorm is to be reimplemented in derived classes (if at all),
34 : * otherwise, this method will return STATUS_UNDEFINED_FUNCTION.
35 : * Use the class's #category to tell whether this is implemented.
36 : * It is highly recommended to implement dualNorm for all Norms.
37 : */
38 : return ForBESUtils::STATUS_UNDEFINED_FUNCTION;
39 : }
40 :
41 : FunctionOntologicalClass Norm::category() {
42 : return FunctionOntologyRegistry::norm();
43 : }
44 : //LCOV_EXCL_STOP
|