Skip to content

Commit 5e17e43

Browse files
committed
added dot
1 parent 407c8ff commit 5e17e43

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

docs/src/functions.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ huberloss
1212
sqrhingeloss
1313
crossentropy
1414
logisticloss
15-
logbarrier
15+
dot
1616
```
1717

1818
## Nonsmooth functions
@@ -22,6 +22,7 @@ norm
2222
maximum
2323
sumpositive
2424
hingeloss
25+
logbarrier
2526
```
2627

2728
## Inequality constraints

src/syntax/terms/proximalOperators_bind.jl

+14
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,20 @@ f(\\mathbf{x}) = \\sum_i \\max \\{x_i, 0\\}.
207207
sumpositive(ex::AbstractExpression) =
208208
Term(SumPositive(), ex)
209209

210+
import Base: dot
211+
212+
"""
213+
`dot(c::AbstractVector, x::AbstractExpression)`
214+
215+
Applies the function:
216+
```math
217+
f(\\mathbf{x}) = \\mathbf{c}^{T}\\mathbf{x}.
218+
```
219+
"""
220+
dot(c::AbstractVector, ex::AbstractExpression) =
221+
Term(Linear(c), ex)
222+
223+
210224
# Inequalities
211225

212226
import Base: <=

test/test_terms.jl

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ cf = huberloss(x,a)
150150
@test cf.lambda == 1
151151
@test cf.f(~x) == (HuberLoss(a))(~x)
152152

153+
a = randn(size(x))
154+
cf = dot(a,x)
155+
@test cf.lambda == 1
156+
@test cf.f(~x) == (Linear(a))(~x)
157+
153158
#IndBinary
154159
lu = (-1,randn(length(~x)))
155160
cf = x == lu

0 commit comments

Comments
 (0)