void CPCAGrid::BackTransform () { ASSERT_TEMPRANGE (0, 2) ; SMatD m_mTempPP (tempRef (0), m_dwPSub, m_dwPSub) ; SetDiag_sq (!m_mTempPP) ; int dwIdxRef = m_vOrd (0) ; set_neg (*m_vAfinBest) ; m_vAfinBest (dwIdxRef) += 1 ; double dNorm = norm2 (m_vAfinBest) ; if (dNorm > m_dZeroTol) { static const double dSqrt2 = sqrt ((double) 2.0) ; EO<SOP::a_divide>::VSc (*m_vAfinBest, dNorm / dSqrt2) ; EO<SOP::AsaBmC>::MVcVct (!m_mTempPP, m_vAfinBest, m_vAfinBest) ; } SMatD mProjSorted (tempRef (1), m_dwPSub, m_dwPSub) ; mProjSorted.CopyCol_Order_NC (m_mTempPP, *m_vOrd) ; // undo sorting SMatD mOldLoadings (tempRef (2), m_dwP, m_dwPSub) ; // 2do: copying cols should be done in constructor (using GetColRef () CopyCol (!mOldLoadings, m_mL, m_dwCurK, m_dwP) ; sme_matmult (mOldLoadings, mProjSorted, !m_mL.GetColRef (m_dwCurK, m_dwP)) ; sme_matmult_R (TempY (), mProjSorted.GetColRef (1, m_dwPSub), !TempYC ()) ; SwapTempY () ; }
local void do_polarities(Type *type, Bool pos, Bool neg) /* in a positive and/or negative context */ { TypeList *formals; TypeList *actuals; switch (type->ty_class) { case TY_VAR: if (pos) set_pos(type->ty_index); if (neg) set_neg(type->ty_index); when TY_MU: /* * BUG: if the var occurs negatively in the body, * should set both pos and neg. */ do_polarities(type->ty_body, pos, neg); when TY_CONS: if (type->ty_deftype == cur_deftype) { for (actuals = type->ty_args, formals = cur_varlist; actuals != NULL; actuals = actuals->ty_tail, formals = formals->ty_tail) { if (pos) set_equiv(formals->ty_head->ty_index, actuals->ty_head->ty_index); if (neg) set_dual(formals->ty_head->ty_index, actuals->ty_head->ty_index); } } else for (actuals = type->ty_args, formals = type->ty_deftype->dt_varlist; actuals != NULL; actuals = actuals->ty_tail, formals = formals->ty_tail) do_polarities(actuals->ty_head, (pos && formals->ty_head->ty_pos) || (neg && formals->ty_head->ty_neg), (neg && formals->ty_head->ty_pos) || (pos && formals->ty_head->ty_neg)); otherwise: NOT_REACHED; } }