1 //=================================================================================================
2 /*!
3 // \file blaze/math/expressions/DVecNormExpr.h
4 // \brief Header file for the dense vector norm expression
5 //
6 // Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
7 //
8 // This file is part of the Blaze library. You can redistribute it and/or modify it under
9 // the terms of the New (Revised) BSD License. Redistribution and use in source and binary
10 // forms, with or without modification, are permitted provided that the following conditions
11 // are met:
12 //
13 // 1. Redistributions of source code must retain the above copyright notice, this list of
14 // conditions and the following disclaimer.
15 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
16 // of conditions and the following disclaimer in the documentation and/or other materials
17 // provided with the distribution.
18 // 3. Neither the names of the Blaze development group nor the names of its contributors
19 // may be used to endorse or promote products derived from this software without specific
20 // prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 */
33 //=================================================================================================
34
35 #ifndef _BLAZE_MATH_EXPRESSIONS_DVECNORMEXPR_H_
36 #define _BLAZE_MATH_EXPRESSIONS_DVECNORMEXPR_H_
37
38
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42
43 #include <utility>
44 #include <blaze/math/Aliases.h>
45 #include <blaze/math/expressions/DenseVector.h>
46 #include <blaze/math/functors/Abs.h>
47 #include <blaze/math/functors/Bind2nd.h>
48 #include <blaze/math/functors/Cbrt.h>
49 #include <blaze/math/functors/L1Norm.h>
50 #include <blaze/math/functors/L2Norm.h>
51 #include <blaze/math/functors/L3Norm.h>
52 #include <blaze/math/functors/L4Norm.h>
53 #include <blaze/math/functors/LpNorm.h>
54 #include <blaze/math/functors/Noop.h>
55 #include <blaze/math/functors/Pow.h>
56 #include <blaze/math/functors/Pow2.h>
57 #include <blaze/math/functors/Pow3.h>
58 #include <blaze/math/functors/Qdrt.h>
59 #include <blaze/math/functors/SqrAbs.h>
60 #include <blaze/math/functors/Sqrt.h>
61 #include <blaze/math/shims/Evaluate.h>
62 #include <blaze/math/shims/Invert.h>
63 #include <blaze/math/shims/IsZero.h>
64 #include <blaze/math/shims/PrevMultiple.h>
65 #include <blaze/math/SIMD.h>
66 #include <blaze/math/traits/MultTrait.h>
67 #include <blaze/math/typetraits/HasLoad.h>
68 #include <blaze/math/typetraits/HasSIMDAdd.h>
69 #include <blaze/math/typetraits/IsPadded.h>
70 #include <blaze/math/typetraits/IsSIMDEnabled.h>
71 #include <blaze/math/typetraits/UnderlyingBuiltin.h>
72 #include <blaze/system/Optimizations.h>
73 #include <blaze/util/algorithms/Min.h>
74 #include <blaze/util/Assert.h>
75 #include <blaze/util/FunctionTrace.h>
76 #include <blaze/util/IntegralConstant.h>
77 #include <blaze/util/mpl/And.h>
78 #include <blaze/util/mpl/If.h>
79 #include <blaze/util/StaticAssert.h>
80 #include <blaze/util/TypeList.h>
81 #include <blaze/util/Types.h>
82 #include <blaze/util/typetraits/HasMember.h>
83 #include <blaze/util/typetraits/RemoveCVRef.h>
84 #include <blaze/util/typetraits/RemoveReference.h>
85
86
87 namespace blaze {
88
89 //=================================================================================================
90 //
91 // CLASS DEFINITION
92 //
93 //=================================================================================================
94
95 //*************************************************************************************************
96 /*! \cond BLAZE_INTERNAL */
97 /*!\brief Auxiliary helper struct for the dense vector norms.
98 // \ingroup dense_vector
99 */
100 template< typename VT // Type of the dense vector
101 , typename Abs // Type of the abs operation
102 , typename Power > // Type of the power operation
103 struct DVecNormHelper
104 {
105 //**Type definitions****************************************************************************
106 //! Element type of the dense vector expression.
107 using ET = ElementType_t<VT>;
108
109 //! Composite type of the dense vector expression.
110 using CT = RemoveReference_t< CompositeType_t<VT> >;
111 //**********************************************************************************************
112
113 //**********************************************************************************************
114 static constexpr bool value =
115 ( useOptimizedKernels &&
116 CT::simdEnabled &&
117 If_t< HasSIMDEnabled_v<Abs> && HasSIMDEnabled_v<Power>
118 , And_t< GetSIMDEnabled<Abs,ET>, GetSIMDEnabled<Power,ET> >
119 , And_t< HasLoad<Abs>, HasLoad<Power> > >::value &&
120 HasSIMDAdd_v< ElementType_t<CT>, ElementType_t<CT> > );
121 //**********************************************************************************************
122 };
123 /*! \endcond */
124 //*************************************************************************************************
125
126
127
128
129 //=================================================================================================
130 //
131 // GLOBAL FUNCTIONS
132 //
133 //=================================================================================================
134
135 //*************************************************************************************************
136 /*! \cond BLAZE_INTERNAL */
137 /*!\brief Default backend implementation of the norm of a dense vector.
138 // \ingroup dense_vector
139 //
140 // \param dv The given dense vector for the norm computation.
141 // \param abs The functor for the abs operation.
142 // \param power The functor for the power operation.
143 // \param root The functor for the root operation.
144 // \return The norm of the given vector.
145 //
146 // This function implements the performance optimized norm of a dense vector. Due to the
147 // explicit application of the SFINAE principle, this function can only be selected by the
148 // compiler in case vectorization cannot be applied.
149 */
150 template< typename VT // Type of the dense vector
151 , bool TF // Transpose flag
152 , typename Abs // Type of the abs operation
153 , typename Power // Type of the power operation
154 , typename Root > // Type of the root operation
decltype(auto)155 inline decltype(auto) norm_backend( const DenseVector<VT,TF>& dv, Abs abs, Power power, Root root, FalseType )
156 {
157 using CT = CompositeType_t<VT>;
158 using ET = ElementType_t<VT>;
159 using PT = RemoveCVRef_t< decltype( power( abs( std::declval<ET>() ) ) ) >;
160 using RT = RemoveCVRef_t< decltype( evaluate( root( std::declval<PT>() ) ) ) >;
161
162 if( (*dv).size() == 0UL ) return RT{};
163
164 CT tmp( *dv );
165
166 const size_t N( tmp.size() );
167
168 PT norm( power( abs( tmp[0UL] ) ) );
169 size_t i( 1UL );
170
171 for( ; (i+4UL) <= N; i+=4UL ) {
172 norm += power( abs( tmp[i ] ) ) + power( abs( tmp[i+1UL] ) ) +
173 power( abs( tmp[i+2UL] ) ) + power( abs( tmp[i+3UL] ) );
174 }
175 for( ; (i+2UL) <= N; i+=2UL ) {
176 norm += power( abs( tmp[i] ) ) + power( abs( tmp[i+1UL] ) );
177 }
178 for( ; i<N; ++i ) {
179 norm += power( abs( tmp[i] ) );
180 }
181
182 return evaluate( root( norm ) );
183 }
184 /*! \endcond */
185 //*************************************************************************************************
186
187
188 //*************************************************************************************************
189 /*! \cond BLAZE_INTERNAL */
190 /*!\brief SIMD optimized backend implementation of the norm of a dense vector.
191 // \ingroup dense_vector
192 //
193 // \param dv The given dense vector for the norm computation.
194 // \param abs The functor for the abs operation.
195 // \param power The functor for the power operation.
196 // \param root The functor for the root operation.
197 // \return The norm of the given vector.
198 //
199 // This function implements the performance optimized norm of a dense vector. Due to the
200 // explicit application of the SFINAE principle, this function can only be selected by the
201 // compiler in case vectorization can be applied.
202 */
203 template< typename VT // Type of the dense vector
204 , bool TF // Transpose flag
205 , typename Abs // Type of the abs operation
206 , typename Power // Type of the power operation
207 , typename Root > // Type of the root operation
decltype(auto)208 inline decltype(auto) norm_backend( const DenseVector<VT,TF>& dv, Abs abs, Power power, Root root, TrueType )
209 {
210 using CT = CompositeType_t<VT>;
211 using ET = ElementType_t<VT>;
212 using RT = decltype( evaluate( root( std::declval<ET>() ) ) );
213
214 static constexpr size_t SIMDSIZE = SIMDTrait<ET>::size;
215
216 if( (*dv).size() == 0UL ) return RT{};
217
218 CT tmp( *dv );
219
220 const size_t N( tmp.size() );
221
222 constexpr bool remainder( !IsPadded_v< RemoveReference_t<VT> > );
223
224 const size_t ipos( remainder ? prevMultiple( N, SIMDSIZE ) : N );
225 BLAZE_INTERNAL_ASSERT( ipos <= N, "Invalid end calculation" );
226
227 size_t i( 0UL );
228 ET norm{};
229
230 if( SIMDSIZE*3UL < ipos )
231 {
232 SIMDTrait_t<ET> xmm1{}, xmm2{}, xmm3{}, xmm4{};
233
234 for( ; (i+SIMDSIZE*3UL) < ipos; i+=SIMDSIZE*4UL ) {
235 xmm1 += power( abs( tmp.load(i ) ) );
236 xmm2 += power( abs( tmp.load(i+SIMDSIZE ) ) );
237 xmm3 += power( abs( tmp.load(i+SIMDSIZE*2UL) ) );
238 xmm4 += power( abs( tmp.load(i+SIMDSIZE*3UL) ) );
239 }
240 for( ; (i+SIMDSIZE) < ipos; i+=SIMDSIZE*2UL ) {
241 xmm1 += power( abs( tmp.load(i ) ) );
242 xmm2 += power( abs( tmp.load(i+SIMDSIZE) ) );
243 }
244 for( ; i<ipos; i+=SIMDSIZE ) {
245 xmm1 += power( abs( tmp.load(i) ) );
246 }
247
248 norm = sum( xmm1 + xmm2 + xmm3 + xmm4 );
249 }
250 else if( SIMDSIZE < ipos )
251 {
252 SIMDTrait_t<ET> xmm1{}, xmm2{};
253
254 for( ; (i+SIMDSIZE) < ipos; i+=SIMDSIZE*2UL ) {
255 xmm1 += power( abs( tmp.load(i ) ) );
256 xmm2 += power( abs( tmp.load(i+SIMDSIZE) ) );
257 }
258 for( ; i<ipos; i+=SIMDSIZE ) {
259 xmm1 += power( abs( tmp.load(i) ) );
260 }
261
262 norm = sum( xmm1 + xmm2 );
263 }
264 else
265 {
266 SIMDTrait_t<ET> xmm1{};
267
268 for( ; i<ipos; i+=SIMDSIZE ) {
269 xmm1 += power( abs( tmp.load(i) ) );
270 }
271
272 norm = sum( xmm1 );
273 }
274
275 for( ; remainder && i<N; ++i ) {
276 norm += power( abs( tmp[i] ) );
277 }
278
279 return evaluate( root( norm ) );
280 }
281 /*! \endcond */
282 //*************************************************************************************************
283
284
285 //*************************************************************************************************
286 /*! \cond BLAZE_INTERNAL */
287 /*!\brief Computes a custom norm for the given dense vector.
288 // \ingroup dense_vector
289 //
290 // \param dv The given dense vector for the norm computation.
291 // \param abs The functor for the abs operation.
292 // \param power The functor for the power operation.
293 // \param root The functor for the root operation.
294 // \return The norm of the given dense vector.
295 //
296 // This function computes a custom norm of the given dense vector by means of the given functors.
297 // The following example demonstrates the computation of the L2 norm by means of the blaze::Noop,
298 // blaze::Pow2 and blaze::Sqrt functors:
299
300 \code
301 blaze::DynamicVector<double> a;
302 // ... Resizing and initialization
303 const double l2 = norm( a, blaze::Noop(), blaze::Pow2(), blaze::Sqrt() );
304 \endcode
305 */
306 template< typename VT // Type of the dense vector
307 , bool TF // Transpose flag
308 , typename Abs // Type of the abs operation
309 , typename Power // Type of the power operation
310 , typename Root > // Type of the root operation
decltype(auto)311 inline decltype(auto) norm_backend( const DenseVector<VT,TF>& dv, Abs abs, Power power, Root root )
312 {
313 return norm_backend( *dv, abs, power, root, Bool_t< DVecNormHelper<VT,Abs,Power>::value >() );
314 }
315 /*! \endcond */
316 //*************************************************************************************************
317
318
319 //*************************************************************************************************
320 /*!\brief Computes the L2 norm for the given dense vector.
321 // \ingroup dense_vector
322 //
323 // \param dv The given dense vector for the norm computation.
324 // \return The L2 norm of the given dense vector.
325 //
326 // This function computes the L2 norm of the given dense vector:
327
328 \code
329 blaze::DynamicVector<double> a;
330 // ... Resizing and initialization
331 const double l2 = norm( a );
332 \endcode
333 */
334 template< typename VT // Type of the dense vector
335 , bool TF > // Transpose flag
decltype(auto)336 inline decltype(auto) norm( const DenseVector<VT,TF>& dv )
337 {
338 BLAZE_FUNCTION_TRACE;
339
340 return norm_backend( *dv, SqrAbs(), Noop(), Sqrt() );
341 }
342 //*************************************************************************************************
343
344
345 //*************************************************************************************************
346 /*!\brief Computes the squared L2 norm for the given dense vector.
347 // \ingroup dense_vector
348 //
349 // \param dv The given dense vector for the norm computation.
350 // \return The squared L2 norm of the given dense vector.
351 //
352 // This function computes the squared L2 norm of the given dense vector:
353
354 \code
355 blaze::DynamicVector<double> a;
356 // ... Resizing and initialization
357 const double l2 = sqrNorm( a );
358 \endcode
359 */
360 template< typename VT // Type of the dense vector
361 , bool TF > // Transpose flag
decltype(auto)362 inline decltype(auto) sqrNorm( const DenseVector<VT,TF>& dv )
363 {
364 BLAZE_FUNCTION_TRACE;
365
366 return norm_backend( *dv, SqrAbs(), Noop(), Noop() );
367 }
368 //*************************************************************************************************
369
370
371 //*************************************************************************************************
372 /*!\brief Computes the L1 norm for the given dense vector.
373 // \ingroup dense_vector
374 //
375 // \param dv The given dense vector for the norm computation.
376 // \return The L1 norm of the given dense vector.
377 //
378 // This function computes the L1 norm of the given dense vector:
379
380 \code
381 blaze::DynamicVector<double> a;
382 // ... Resizing and initialization
383 const double l1 = l1Norm( a );
384 \endcode
385 */
386 template< typename VT // Type of the dense vector
387 , bool TF > // Transpose flag
decltype(auto)388 inline decltype(auto) l1Norm( const DenseVector<VT,TF>& dv )
389 {
390 BLAZE_FUNCTION_TRACE;
391
392 return norm_backend( *dv, Abs(), Noop(), Noop() );
393 }
394 //*************************************************************************************************
395
396
397 //*************************************************************************************************
398 /*!\brief Computes the L2 norm for the given dense vector.
399 // \ingroup dense_vector
400 //
401 // \param dv The given dense vector for the norm computation.
402 // \return The L2 norm of the given dense vector.
403 //
404 // This function computes the L2 norm of the given dense vector:
405
406 \code
407 blaze::DynamicVector<double> a;
408 // ... Resizing and initialization
409 const double l2 = l2Norm( a );
410 \endcode
411 */
412 template< typename VT // Type of the dense vector
413 , bool TF > // Transpose flag
decltype(auto)414 inline decltype(auto) l2Norm( const DenseVector<VT,TF>& dv )
415 {
416 BLAZE_FUNCTION_TRACE;
417
418 return norm_backend( *dv, SqrAbs(), Noop(), Sqrt() );
419 }
420 //*************************************************************************************************
421
422
423 //*************************************************************************************************
424 /*!\brief Computes the L3 norm for the given dense vector.
425 // \ingroup dense_vector
426 //
427 // \param dv The given dense vector for the norm computation.
428 // \return The L3 norm of the given dense vector.
429 //
430 // This function computes the L3 norm of the given dense vector:
431
432 \code
433 blaze::DynamicVector<double> a;
434 // ... Resizing and initialization
435 const double l3 = l3Norm( a );
436 \endcode
437 */
438 template< typename VT // Type of the dense vector
439 , bool TF > // Transpose flag
decltype(auto)440 inline decltype(auto) l3Norm( const DenseVector<VT,TF>& dv )
441 {
442 BLAZE_FUNCTION_TRACE;
443
444 return norm_backend( *dv, Abs(), Pow3(), Cbrt() );
445 }
446 //*************************************************************************************************
447
448
449 //*************************************************************************************************
450 /*!\brief Computes the L4 norm for the given dense vector.
451 // \ingroup dense_vector
452 //
453 // \param dv The given dense vector for the norm computation.
454 // \return The L4 norm of the given dense vector.
455 //
456 // This function computes the L4 norm of the given dense vector:
457
458 \code
459 blaze::DynamicVector<double> a;
460 // ... Resizing and initialization
461 const double l4 = l4Norm( a );
462 \endcode
463 */
464 template< typename VT // Type of the dense vector
465 , bool TF > // Transpose flag
decltype(auto)466 inline decltype(auto) l4Norm( const DenseVector<VT,TF>& dv )
467 {
468 BLAZE_FUNCTION_TRACE;
469
470 return norm_backend( *dv, SqrAbs(), Pow2(), Qdrt() );
471 }
472 //*************************************************************************************************
473
474
475 //*************************************************************************************************
476 /*!\brief Computes the Lp norm for the given dense vector.
477 // \ingroup dense_vector
478 //
479 // \param dv The given dense vector for the norm computation.
480 // \param p The norm parameter (p > 0).
481 // \return The Lp norm of the given dense vector.
482 //
483 // This function computes the Lp norm of the given dense vector, where the norm is specified by
484 // the runtime argument \a p:
485
486 \code
487 blaze::DynamicVector<double> a;
488 // ... Resizing and initialization
489 const double lp = lpNorm( a, 2.3 );
490 \endcode
491
492 // \note The norm parameter \a p is expected to be larger than 0. This precondition is only checked
493 // by a user assertion.
494 */
495 template< typename VT // Type of the dense vector
496 , bool TF // Transpose flag
497 , typename ST > // Type of the norm parameter
decltype(auto)498 inline decltype(auto) lpNorm( const DenseVector<VT,TF>& dv, ST p )
499 {
500 BLAZE_FUNCTION_TRACE;
501
502 BLAZE_USER_ASSERT( !isZero( p ), "Invalid p for Lp norm detected" );
503
504 using ScalarType = MultTrait_t< UnderlyingBuiltin_t<VT>, decltype( inv( p ) ) >;
505 using UnaryPow = Bind2nd<Pow,ScalarType>;
506 return norm_backend( *dv, Abs(), UnaryPow( Pow(), p ), UnaryPow( Pow(), inv( p ) ) );
507 }
508 //*************************************************************************************************
509
510
511 //*************************************************************************************************
512 /*!\brief Computes the Lp norm for the given dense vector.
513 // \ingroup dense_vector
514 //
515 // \param dv The given dense vector for the norm computation.
516 // \return The Lp norm of the given dense vector.
517 //
518 // This function computes the Lp norm of the given dense vector, where the norm is specified by
519 // the runtime argument \a P:
520
521 \code
522 blaze::DynamicVector<double> a;
523 // ... Resizing and initialization
524 const double lp = lpNorm<2>( a );
525 \endcode
526
527 // \note The norm parameter \a P is expected to be larger than 0. A value of 0 results in a
528 // compile time error!.
529 */
530 template< size_t P // Compile time norm parameter
531 , typename VT // Type of the dense vector
532 , bool TF > // Transpose flag
decltype(auto)533 inline decltype(auto) lpNorm( const DenseVector<VT,TF>& dv )
534 {
535 BLAZE_STATIC_ASSERT_MSG( P > 0UL, "Invalid norm parameter detected" );
536
537 using Norms = TypeList< L1Norm, L2Norm, L3Norm, L4Norm, LpNorm<P> >;
538 using Norm = typename TypeAt< Norms, min( P-1UL, 4UL ) >::Type;
539
540 return Norm()( *dv );
541 }
542 //*************************************************************************************************
543
544
545 //*************************************************************************************************
546 /*!\brief Computes the infinity norm for the given dense vector.
547 // \ingroup dense_vector
548 //
549 // \param dv The given dense vector for the norm computation.
550 // \return The infinity norm of the given dense vector.
551 //
552 // This function computes the infinity norm of the given dense vector:
553
554 \code
555 blaze::DynamicVector<double> a;
556 // ... Resizing and initialization
557 const double linf = linfNorm( a );
558 \endcode
559 */
560 template< typename VT // Type of the dense vector
561 , bool TF > // Transpose flag
decltype(auto)562 inline decltype(auto) linfNorm( const DenseVector<VT,TF>& dv )
563 {
564 BLAZE_FUNCTION_TRACE;
565
566 return max( abs( *dv ) );
567 }
568 //*************************************************************************************************
569
570
571 //*************************************************************************************************
572 /*!\brief Computes the maximum norm for the given dense vector.
573 // \ingroup dense_vector
574 //
575 // \param dv The given dense vector for the norm computation.
576 // \return The maximum norm of the given dense vector.
577 //
578 // This function computes the maximum norm of the given dense vector:
579
580 \code
581 blaze::DynamicVector<double> a;
582 // ... Resizing and initialization
583 const double max = maxNorm( a );
584 \endcode
585 */
586 template< typename VT // Type of the dense vector
587 , bool TF > // Transpose flag
decltype(auto)588 inline decltype(auto) maxNorm( const DenseVector<VT,TF>& dv )
589 {
590 BLAZE_FUNCTION_TRACE;
591
592 return linfNorm( *dv );
593 }
594 //*************************************************************************************************
595
596
597 //*************************************************************************************************
598 /*!\brief Calculation of the square length (magnitude) of the dense vector \f$|\vec{a}|^2\f$.
599 // \ingroup dense_vector
600 //
601 // \param dv The given dense vector.
602 // \return The square length (magnitude) of the dense vector.
603 //
604 // This function calculates the actual square length (magnitude) of the dense vector. The
605 // function has the same effect as calling the \a sqrNorm() function on the dense vector.
606 */
607 template< typename VT // Type of the dense vector
608 , bool TF > // Transpose flag
decltype(auto)609 inline decltype(auto) sqrLength( const DenseVector<VT,TF>& dv )
610 {
611 return sqrNorm( *dv );
612 }
613 //*************************************************************************************************
614
615
616 //*************************************************************************************************
617 /*!\brief Calculation of the length (magnitude) of the dense vector \f$|\vec{a}|\f$.
618 // \ingroup dense_vector
619 //
620 // \param dv The given dense vector.
621 // \return The length (magnitude) of the dense vector.
622 //
623 // This function calculates the actual length (magnitude) of the dense vector. The function has
624 // the same effect as calling the \a norm() function on the dense vector.
625 */
626 template< typename VT // Type of the dense vector
627 , bool TF > // Transpose flag
decltype(auto)628 inline decltype(auto) length( const DenseVector<VT,TF>& dv )
629 {
630 return norm( *dv );
631 }
632 //*************************************************************************************************
633
634 } // namespace blaze
635
636 #endif
637