func (p *Projection) ClipGradient(base, gradient Parameter) {
	for iter := base.IndexIterator(); iter.Next(); {
		i := iter.Index()
		// We clip gradient to zero if it is out of bound
		if base.Get(i) <= p.lower_bound.Get(i) {
			gradient.Set(i, min(gradient.Get(i), 0))
		}
		if base.Get(i) >= p.upper_bound.Get(i) {
			gradient.Set(i, max(gradient.Get(i), 0))
		}
	}
}
// We assume the base and gradient are in the same dimensions. In another words,
// the IndexIterator will return the same from base and gradient.
We assume the base and gradient are in the same dimensions. In another words,
the IndexIterator will return the same from base and gradient.
// We assume the base and gradient are in the same dimensions . In another words // the IndexIterator will return the same from base and gradient .
func (p *Projection) ClipGradient(base, gradient Parameter) {
	for iter := base.IndexIterator(); iter.Next(); {
		i := iter.Index()
		if base.Get(i) <= p.lower_bound.Get(i) {
			gradient.Set(i, min(gradient.Get(i), 0))
		}
		if base.Get(i) >= p.upper_bound.Get(i) {
			gradient.Set(i, max(gradient.Get(i), 0))
		}
	}
}
func ( p * Projection ) ClipGradient ( base , gradient Parameter ) { for iter := base . IndexIterator ( ) ; iter . Next ( ) ; { i := iter . Index ( ) if base . Get ( i ) <= p . lower_bound . Get ( i ) { gradient . Set ( i , min ( gradient . Get ( i ) , 0 ) ) } if base . Get ( i ) >= p . upper_bound . Get ( i ) { gradient . Set ( i , max ( gradient . Get ( i ) , 0 ) ) } } }
We assume the base and gradient are in the same dimensions.
We assume the base and gradient are in the same dimensions .
// We clip gradient to zero if it is out of bound