void CreateDiscussionsHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			universal_resource error_desc;
			ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			error_desc = XL("biz.CreateDiscussions.fail");

			callback_(true, error_desc, jobj);
		}else{
			if(iq.findExtension(kExtUser_iq_filter_creatediscussions))
			{
				boost::shared_ptr<gloox::Tag> tag(iq.findExtension(kExtUser_iq_filter_creatediscussions)->tag());
				if (tag)
				{
					gloox::Tag* tag2 = tag->findChild("item");
					if (tag)
					{
						jobj["session_id"] = gWrapInterface::instance().append_discussions_domain(tag2->findAttribute("id"));
						jobj["group_name"] = tag2->findAttribute("topic");

						callback_(false,XL(""),jobj);
						return;
					}
				}
			}
			ELOG("app")->error(WCOOL(L"创建讨论组时服务端返回的数据格式错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			callback_(true, XL("biz.CreateDiscussions.fail"), jobj);
		}
	}
	void GroupsAdminManageMemberHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			const Error* e = iq.error();
			if (!e)
			{
				callback_(true,XL("biz.GroupsAdminManageMember.fail"));
				return;
			}
			if ( e->error() == StanzaErrorBadRequest)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,请求协议错误!。"));
				callback_(true,XL("biz.crwod.iq_error.bad-request"));
			}
			else if (e->error() == StanzaErrorInternalServerError)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,处理错误(服务器处理错误)。"));
				callback_(true,XL("biz.crwod.iq_error.internal-server-error"));
			}
			else if (e->error() == StanzaErrorGone)
			{
				universal_resource err;
				err.res_key="biz.crwod.iq_error.answer_apply_gone";
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,消息已过期!"));
				callback_(false,err);
			}
			else if (e->error() == StanzaErrorForbidden)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,自己不是管理员"));
				callback_(true,XL("biz.crwod.iq_error.admin_forbidden"));
			}			
			else if (e->error() == StanzaErrorResourceConstraint)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,群成员已经满"));
				callback_(true,XL("biz.crwod.iq_error.admin_resource-constraint"));
			}
			else if (e->error() == StanzaErrorConflict)
			{
				universal_resource err;
				err.res_key="biz.crwod.iq_error.admin_Conflict";
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,该成员已加入群"));
				callback_(false,err);
			}
			else if (e->error() == StanzaErrorItemNotFound)
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,找不到此群。"));
				callback_(true,XL("biz.crwod.iq_error.item-not-found"));
			}else
			{
				ELOG("app")->error(WCOOL(L"管理员审批成员加入时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.GroupsAdminManageMember.fail"));
			}

		}else{
			callback_(false,XL(""));		
		}
	}
	void ChangeDiscussionsNameHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			universal_resource error_desc;
			ELOG("app")->error(WCOOL(L"讨论组改名时服务端返回错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			error_desc = XL("biz.ChangeDiscussionsName.fail");
			callback_(true, error_desc);
		}
		else
		{
			callback_(false, XL(""));
		}
	}
Example #4
0
inline void
TrmmLLNA
( UnitOrNonUnit diag,
  T alpha, const DistMatrix<T>& L,
                 DistMatrix<T>& X )
{
#ifndef RELEASE
    PushCallStack("internal::TrmmLLNA");
    if( L.Grid() != X.Grid() )
        throw std::logic_error
        ("L and X must be distributed over the same grid");
    if( L.Height() != L.Width() || L.Width() != X.Height() )
    {
        std::ostringstream msg;
        msg << "Nonconformal TrmmLLNA: \n"
            << "  L ~ " << L.Height() << " x " << L.Width() << "\n"
            << "  X ~ " << X.Height() << " x " << X.Width() << "\n";
        throw std::logic_error( msg.str().c_str() );
    }
#endif
    const Grid& g = L.Grid();

    DistMatrix<T>
        XL(g), XR(g),
        X0(g), X1(g), X2(g);

    DistMatrix<T,VR,  STAR> X1_VR_STAR(g);
    DistMatrix<T,STAR,MR  > X1Trans_STAR_MR(g);
    DistMatrix<T,MC,  STAR> Z1_MC_STAR(g);

    X1_VR_STAR.AlignWith( L );
    X1Trans_STAR_MR.AlignWith( L );
    Z1_MC_STAR.AlignWith( L );

    PartitionRight( X, XL, XR, 0 );
    while( XL.Width() < X.Width() )
    {
        RepartitionRight
        ( XL, /**/ XR,
          X0, /**/ X1, X2 );

        Zeros( X1.Height(), X1.Width(), Z1_MC_STAR );
        //--------------------------------------------------------------------//
        X1_VR_STAR = X1;
        X1Trans_STAR_MR.TransposeFrom( X1_VR_STAR );
        LocalTrmmAccumulateLLN
        ( TRANSPOSE, diag, alpha, L, X1Trans_STAR_MR, Z1_MC_STAR );

        X1.SumScatterFrom( Z1_MC_STAR );
        //--------------------------------------------------------------------//

        SlidePartitionRight
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
/*
 <iq type=’result’ from=’[email protected]’ to=’[email protected]’>
  	<query xmlns=’groups:dismiss’>
  		<item name=’吃货群’ />
  </query>
  </iq>
*/
void GetGroupsRecentMessagesHandler::handleIqID( const IQ& iq, int context )
{
    json::jobject jobj;
    if (iq.m_subtype != gloox::IQ::Result)
    {
        universal_resource error_group;
        ELOG("app")->error(WCOOL(L"获取群最近消息时服务端返回错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
        error_group = XL("biz.GetGroupsRecentMessages.fail");
    }
}
	void OrganizationShowHandller::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj = json::jobject();
		if (iq.m_subtype != gloox::IQ::Result)
		{
			universal_resource error_desc;
			ELOG("app")->error(WCOOL(L"组织结构树查看权限获取错误") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			error_desc = XL("biz.OrganizationShowHandller.fail");
			callback_(true, error_desc,jobj);
		}
		else
		{
			boost::shared_ptr<gloox::Tag> ptag(iq.findExtension(kExtUser_iq_filter_organization_show)->tag());
			if (ptag)
			{
				gloox::Tag* tag_basic_permission = ptag->findChild("basic_permissions");
				if (tag_basic_permission)
				{
					ConstTagList ptag_list = tag_basic_permission->findTagList("//permission");
					for (ConstTagList::iterator it = ptag_list.begin(); it != ptag_list.end(); ++it)
					{
						if ((*it)->findAttribute("name") == "show_organization")
						{
							if ((*it)->cdata() == "true")
							{
								jobj["is_show_organization"] = true;
							}
							else
							{
								jobj["is_show_organization"] = false;
							}
							callback_(false, XL(""),jobj);
						}
					}
				}
			}
		}
	}
	/*
	 <iq type=’result’from=’[email protected]’ to=’[email protected]’>
	 <queryxmlns=’groups:share:file:delete’>
	 <item id=‘2’ />
	 </query>
	 </iq>
	*/
	void InviteIntoGroupsHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			const Error* e = iq.error();
			if (!e)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.InviteIntoGroups.fail"));
				return;
			}

			if ( e->error() == StanzaErrorBadRequest)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,请求协议错误!。"));
				callback_(true,XL("biz.crwod.iq_error.bad-request"));
			}
			else if (e->error() == StanzaErrorInternalServerError)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,处理错误(服务器处理错误)。"));
				callback_(true,XL("biz.crwod.iq_error.internal-server-error"));
			}
			else if (e->error() == StanzaErrorConflict)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,被邀请人已经在群里。"));
				callback_(true,XL("biz.crwod.iq_error.invite_conflict"));
			}
			else if (e->error() == StanzaErrorResourceConstraint)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,群已经满员。"));
				callback_(true,XL("biz.crwod.iq_error.invite_resource-constraint"));
			}
			else if (e->error() == StanzaErrorNotAllowed)
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,邀请人不是管理员。"));
				callback_(true,XL("biz.crwod.iq_error.invite_not-allowed"));
			}else
			{
				ELOG("app")->error(WCOOL(L"邀请加入群时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.InviteIntoGroups.fail"));
			}
		}else{
			callback_(false,XL(""));
		}
	}
Example #8
0
void user::disposeMessage( json::jobject jobj, UIVCallback callback )
{
	IN_TASK_THREAD_WORKx(user::disposeMessage, jobj, callback);

	std::string inString;
	if (jobj.arr_size()) {
		inString = " where rowid in (" + jobj[0].get<std::string>();
		for (int i=1; i<jobj.arr_size() ; ++i)
		{
			inString += "," + (boost::lexical_cast<std::string>(jobj[i].get<int>()));
		}
		inString += ");";
	}

	get_parent_impl()->bizLocalConfig_->removeMessageBy( "fakedata", inString);

	if (!callback.empty())
	{
		callback(false, XL(""));
	}
}
	void GetGroupsShareListHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj,items,sets;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			const Error* e = iq.error();
			if (!e)
			{
				callback_(true,XL("biz.GetGroupsShareList.fail"),jobj);
				return;
			}
			if ( e->error() == StanzaErrorBadRequest)
			{
				ELOG("app")->error(WCOOL(L"取群共享列表时,请求协议错误!。"));
				callback_(true,XL("biz.crwod.iq_error.bad-request"),jobj);
			}
			else if (e->error() == StanzaErrorInternalServerError)
			{
				ELOG("app")->error(WCOOL(L"取群共享列表时,处理错误(服务器处理错误)。"));
				callback_(true,XL("biz.crwod.iq_error.internal-server-error"),jobj);
			}
			else if (e->error() == StanzaErrorItemNotFound)
			{
				ELOG("app")->error(WCOOL(L"取群共享列表时,找不到此群。"));
				callback_(true,XL("biz.crwod.iq_error.item-not-found"),jobj);
			}else
			{
				ELOG("app")->error(WCOOL(L"取群共享列表时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.GetGroupsShareList.fail"),jobj);
			}

		}else{
			if(iq.findExtension(kExtUser_iq_filter_getgroupssharelist))
			{
				boost::shared_ptr<gloox::Tag> tag(iq.findExtension(kExtUser_iq_filter_getgroupssharelist)->tag());
				if (tag)
				{
					//循环取得item
					gloox::TagList item;
					item = tag->findChildren("item");
					TagList::const_iterator it = item.begin();

					gloox::Tag* setTag = tag->findChild("set");
					if (setTag)
					{
						if (setTag->findChild( "index" ))
						{
							sets["index"]= setTag->findChild( "index" )->findCData( "index" );
						}
						if (setTag->findChild( "max" ))
						{
							sets["max"]= setTag->findChild( "max" )->findCData( "max" );
						}
						if (setTag->findChild( "total" ))
						{
							sets["total"]= setTag->findChild( "total" )->findCData( "total" );
						}
					}
					
					jobj["set"]=sets;
					for( ; it != item.end(); ++it )
					{
						json::jobject data;
						
						data["id"] = (*it)->findAttribute( "id" );
						data["name"] = (*it)->findAttribute( "name" );
						data["size"]  = (*it)->findAttribute( "size" );
						data["owner_jid"] = (*it)->findAttribute( "owner_jid" );
						
						if ((*it)->findAttribute( "download_count" ).empty())
						{
							data["download_count"] = "0";
						}
						else
						{
							data["download_count"] = (*it)->findAttribute( "download_count" );
						}
						
						std::string timestamp = (*it)->findAttribute( "create_time" );
						data["timestamp"] = timestamp;
						if (!timestamp.empty())
						{
							boost::posix_time::ptime t = boost::posix_time::from_time_t(boost::lexical_cast<intmax_t>(timestamp)/1000);
							boost::posix_time::ptime local_time = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(t);
							data["create_time"] = epius::time_format(local_time);
						}
						else
						{
							data["create_time"] = "";
						}
						
						data["owner_name"] = (*it)->findAttribute( "owner_name" );
						data["uri"] = (*it)->findAttribute( "uri" );
						items.arr_push(data);
					}
					jobj["list"]=items;
					if (!callback_.empty())
					{
						callback_(false, XL(""), jobj);
					}

					return;
				}
			}

			ELOG("app")->error(WCOOL(L"取群共享列表时服务端返回的数据格式错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			if (!callback_.empty())
			{
				universal_resource error_desc;
				error_desc = XL("biz.GetGroupsShareList.fail");
				callback_(true, error_desc, jobj);
			}
		}
	}
Example #10
0
inline void
TrsmRLT
( Orientation orientation, UnitOrNonUnit diag,
  F alpha, const DistMatrix<F>& L, DistMatrix<F>& X,
  bool checkIfSingular )
{
#ifndef RELEASE
    CallStackEntry entry("internal::TrsmRLT");
    if( orientation == NORMAL )
        LogicError("TrsmRLT expects a (Conjugate)Transpose option");
#endif
    const Grid& g = L.Grid();

    // Matrix views
    DistMatrix<F> 
        LTL(g), LTR(g),  L00(g), L01(g), L02(g),
        LBL(g), LBR(g),  L10(g), L11(g), L12(g),
                         L20(g), L21(g), L22(g);

    DistMatrix<F> XL(g), XR(g),
                  X0(g), X1(g), X2(g);

    // Temporary distributions
    DistMatrix<F,STAR,STAR> L11_STAR_STAR(g);
    DistMatrix<F,VR,  STAR> L21_VR_STAR(g);
    DistMatrix<F,STAR,MR  > L21AdjOrTrans_STAR_MR(g);
    DistMatrix<F,VC,  STAR> X1_VC_STAR(g);
    DistMatrix<F,STAR,MC  > X1Trans_STAR_MC(g);

    // Start the algorithm
    Scale( alpha, X );
    LockedPartitionDownDiagonal
    ( L, LTL, LTR,
         LBL, LBR, 0 );
    PartitionRight( X, XL, XR, 0 );
    while( XR.Width() > 0 )
    {
        LockedRepartitionDownDiagonal
        ( LTL, /**/ LTR,  L00, /**/ L01, L02,
         /*************/ /******************/
               /**/       L10, /**/ L11, L12,
          LBL, /**/ LBR,  L20, /**/ L21, L22 );

        RepartitionRight
        ( XL, /**/     XR,
          X0, /**/ X1, X2 );

        X1_VC_STAR.AlignWith( X2 );
        X1Trans_STAR_MC.AlignWith( X2 );
        L21_VR_STAR.AlignWith( X2 );
        L21AdjOrTrans_STAR_MR.AlignWith( X2 );
        //--------------------------------------------------------------------//
        L11_STAR_STAR = L11; 
        X1_VC_STAR = X1;  
        
        LocalTrsm
        ( RIGHT, LOWER, orientation, diag, 
          F(1), L11_STAR_STAR, X1_VC_STAR, checkIfSingular );

        X1Trans_STAR_MC.TransposeFrom( X1_VC_STAR );
        X1.TransposeFrom( X1Trans_STAR_MC );
        L21_VR_STAR = L21;
        if( orientation == ADJOINT )
            L21AdjOrTrans_STAR_MR.AdjointFrom( L21_VR_STAR );
        else
            L21AdjOrTrans_STAR_MR.TransposeFrom( L21_VR_STAR );

        // X2[MC,MR] -= X1[MC,*] (L21[MR,*])^(T/H)
        //            = X1^T[* ,MC] (L21^(T/H))[*,MR]
        LocalGemm
        ( TRANSPOSE, NORMAL, 
          F(-1), X1Trans_STAR_MC, L21AdjOrTrans_STAR_MR, F(1), X2 );
        //--------------------------------------------------------------------//

        SlideLockedPartitionDownDiagonal
        ( LTL, /**/ LTR,  L00, L01, /**/ L02,
               /**/       L10, L11, /**/ L12,
         /*************/ /******************/
          LBL, /**/ LBR,  L20, L21, /**/ L22 );

        SlidePartitionRight
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );
    }
}
Example #11
0
inline void
TrsmRUN
( UnitOrNonUnit diag, F alpha, const DistMatrix<F>& U, DistMatrix<F>& X,
  bool checkIfSingular )
{
#ifndef RELEASE
    PushCallStack("internal::TrsmRUN");
#endif
    const Grid& g = U.Grid();

    // Matrix views
    DistMatrix<F> 
        UTL(g), UTR(g),  U00(g), U01(g), U02(g),
        UBL(g), UBR(g),  U10(g), U11(g), U12(g),
                         U20(g), U21(g), U22(g);

    DistMatrix<F> XL(g), XR(g),
                  X0(g), X1(g), X2(g);

    // Temporary distributions
    DistMatrix<F,STAR,STAR> U11_STAR_STAR(g); 
    DistMatrix<F,STAR,MR  > U12_STAR_MR(g);
    DistMatrix<F,VC,  STAR> X1_VC_STAR(g);    
    DistMatrix<F,STAR,MC  > X1Trans_STAR_MC(g);
    
    // Start the algorithm
    Scale( alpha, X );
    LockedPartitionDownDiagonal
    ( U, UTL, UTR,
         UBL, UBR, 0 );
    PartitionRight( X, XL, XR, 0 );
    while( XR.Width() > 0 )
    {
        LockedRepartitionDownDiagonal
        ( UTL, /**/ UTR,  U00, /**/ U01, U02,
         /*************/ /******************/
               /**/       U10, /**/ U11, U12, 
          UBL, /**/ UBR,  U20, /**/ U21, U22 );

        RepartitionRight
        ( XL, /**/     XR,
          X0, /**/ X1, X2 ); 

        X1_VC_STAR.AlignWith( X2 );
        X1Trans_STAR_MC.AlignWith( X2 );
        U12_STAR_MR.AlignWith( X2 );
        //--------------------------------------------------------------------//
        U11_STAR_STAR = U11; 
        X1_VC_STAR = X1;

        LocalTrsm
        ( RIGHT, UPPER, NORMAL, diag, F(1), U11_STAR_STAR, X1_VC_STAR,
          checkIfSingular );

        X1Trans_STAR_MC.TransposeFrom( X1_VC_STAR );
        X1.TransposeFrom( X1Trans_STAR_MC );
        U12_STAR_MR = U12; 

        // X2[MC,MR] -= X1[MC,* ] U12[* ,MR]
        //            = X1^T[* ,MC] U12[* ,MR]
        LocalGemm
        ( TRANSPOSE, NORMAL, F(-1), X1Trans_STAR_MC, U12_STAR_MR, F(1), X2 );
        //--------------------------------------------------------------------//
        X1_VC_STAR.FreeAlignments();
        X1Trans_STAR_MC.FreeAlignments();
        U12_STAR_MR.FreeAlignments();

        SlideLockedPartitionDownDiagonal
        ( UTL, /**/ UTR,  U00, U01, /**/ U02,
               /**/       U10, U11, /**/ U12,
         /*************/ /******************/
          UBL, /**/ UBR,  U20, U21, /**/ U22 );

        SlidePartitionRight
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
Example #12
0
inline void
TrmmRLNCOld
( UnitOrNonUnit diag,
  T alpha, const DistMatrix<T>& L,
                 DistMatrix<T>& X )
{
#ifndef RELEASE
    PushCallStack("internal::TrmmRLNCOld");
    if( L.Grid() != X.Grid() )
        throw std::logic_error
        ("L and X must be distributed over the same grid");
    if( L.Height() != L.Width() || X.Width() != L.Height() )
    {
        std::ostringstream msg;
        msg << "Nonconformal TrmmRLNC: \n"
            << "  L ~ " << L.Height() << " x " << L.Width() << "\n"
            << "  X ~ " << X.Height() << " x " << X.Width() << "\n";
        throw std::logic_error( msg.str().c_str() );
    }
#endif
    const Grid& g = L.Grid();

    // Matrix views
    DistMatrix<T> 
        LTL(g), LTR(g),  L00(g), L01(g), L02(g),
        LBL(g), LBR(g),  L10(g), L11(g), L12(g),
                         L20(g), L21(g), L22(g);

    DistMatrix<T> XL(g), XR(g),
                  X0(g), X1(g), X2(g);

    // Temporary distributions
    DistMatrix<T,STAR,STAR> L11_STAR_STAR(g);
    DistMatrix<T,MR,  STAR> L21_MR_STAR(g);
    DistMatrix<T,VC,  STAR> X1_VC_STAR(g);
    DistMatrix<T,MC,  STAR> D1_MC_STAR(g);

    // Start the algorithm
    Scale( alpha, X );
    LockedPartitionDownDiagonal
    ( L, LTL, LTR,
         LBL, LBR, 0 );
    PartitionRight( X, XL, XR, 0 );
    while( XR.Width() > 0 )
    {
        LockedRepartitionDownDiagonal
        ( LTL, /**/ LTR,  L00, /**/ L01, L02,
         /*************/ /******************/
               /**/       L10, /**/ L11, L12,
          LBL, /**/ LBR,  L20, /**/ L21, L22 );
 
        RepartitionRight
        ( XL, /**/ XR,
          X0, /**/ X1, X2 );

        L21_MR_STAR.AlignWith( X2 );
        D1_MC_STAR.AlignWith( X1 );
        Zeros( X1.Height(), X1.Width(), D1_MC_STAR );
        //--------------------------------------------------------------------//
        X1_VC_STAR = X1;
        L11_STAR_STAR = L11;
        LocalTrmm
        ( RIGHT, LOWER, NORMAL, diag, T(1), L11_STAR_STAR, X1_VC_STAR );
        X1 = X1_VC_STAR;
 
        L21_MR_STAR = L21;
        LocalGemm( NORMAL, NORMAL, T(1), X2, L21_MR_STAR, T(0), D1_MC_STAR );
        X1.SumScatterUpdate( T(1), D1_MC_STAR );
        //--------------------------------------------------------------------//
        L21_MR_STAR.FreeAlignments();
        D1_MC_STAR.FreeAlignments();

        SlideLockedPartitionDownDiagonal
        ( LTL, /**/ LTR,  L00, L01, /**/ L02,
               /**/       L10, L11, /**/ L12,
         /*************/ /******************/
          LBL, /**/ LBR,  L20, L21, /**/ L22 );

        SlidePartitionRight
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
Example #13
0
static void compute_coords(GeometricGraph &G, short TreeColor1, short TreeColor2, tbrin RootBrin,  svector<tbrin> &Father0, svector<tbrin> &Father1, svector<tbrin> &Father2, svector<short> &ecolor, svector<int> &x, svector<int> &y, svector<Tpoint> &Ebend)
  {
  svector<int> marked(1,G.ne(),0); marked.SetName("marked");
  svector<int> Descendants(1,G.nv(),1); Descendants.SetName("Descendants");
  
  tbrin b;
  tvertex u, f0, f1, f2;
  tvertex v0, v1, v2; // roots of T0,T1,T2
  svector<int> Lmax1(1,G.nv(),0);
  svector<int> Lmax2(1,G.nv(),0);
  svector<int> XR(1,G.nv(),0);
  svector<int> XL(1,G.nv(),-1);
  tbrin RootBrin1, RootBrin2;
  RootBrin2 = RootBrin;
  RootBrin1 = -RootBrin;
  b = RootBrin1;
  v0 = G.vin[RootBrin2];
  v1 = G.vin[-RootBrin2];
  v2 = G.vin[-G.acir[-RootBrin2]];
  y[v0] = 0;
  x[v0] = 0;
  x[v2] = 0;

  // Computes ordinates
  while (1)
      {do
          {b = G.cir[b];
          if(b == RootBrin1) break;
          }while (ecolor[b.GetEdge()] != TreeColor1 && !marked[b.GetEdge()]);
      if (b == RootBrin1) break;
      if (!marked[b.GetEdge()])     // Montee dans l'arbre
          {marked[b.GetEdge()] = 1;
          b = -b;
          }
      else               // Descente
          {u = G.vin[b];
          f0 =G.vin[Father0[u]];
          f1 =G.vin[Father1[u]];
          f2 =G.vin[Father2[u]];
          if (f0 != 0) y[u] = Max(y[u],y[f0]+1);
          y[u] = Max(y[u],Min(Lmax1[u],Lmax2[u])+1);
          if (f2 != 0) y[f2] = Max(y[f2], y[u]);
          if (f1 != 0) y[f1] = Max(y[f1], y[u]);
          if (f2 != 0) y[f2] = Max(y[f2], Lmax1[u]+1);
          if (f1 != 0) y[f1] = Max(y[f1], Lmax2[u]+1);
	
          if (f1 != 0)     Lmax1[f1] = Max(Lmax1[f1], y[u]);
          if (f2 != 0)     Lmax2[f2] = Max(Lmax2[f2], y[u]);
          b = -b;
          }
      }
  y[v1] = Max(y[v1], Lmax2[v2]+1);

  // Computes Bends and abscissa
  Fill(marked, 0);
  int current_x=1;
  b = RootBrin2;
  while (1)
      {do
          {b = G.cir[b];
          if(b == RootBrin2)break;
          }while (ecolor[b.GetEdge()] != TreeColor2 && !marked[b.GetEdge()]);
      if (b == RootBrin2) break;
      if (!marked[b.GetEdge()])     // Montee dans l'arbre
	{marked[b.GetEdge()] = 1;
          b = -b;
          }
      else               // Descente
          {u = G.vin[b];
          f0 =G.vin[Father0[u]];
          f1 =G.vin[Father1[u]];
          f2 =G.vin[Father2[u]];
          if (Descendants[u] == 1) 
              {x[u] = current_x;
              XL[u] = current_x;
              XR[u] = current_x;
              current_x++;
              }
          else 
              {if (y[u] == Lmax2[u])
                  x[u] = XR[u];
              else
                  x[u] = XL[u];
              }
          if (f0 != 0) 
              {XR[f0]=XR[u];
              if (XL[f0] == -1)   XL[f0] = XL[u];
              Ebend[b.GetEdge()] = Tpoint(x[u],y[f0]+1);
              }
          if (f1 != 0 && x[u] != XR[u]) 
              Ebend[Father1[u].GetEdge()] = Tpoint(XR[u],y[u]);
          if (f2 != 0 && x[u] != XL[u]) 
              Ebend[Father2[u].GetEdge()] = Tpoint(XL[u],y[u]);
          Descendants[f0] += Descendants[u];
          b = -b;
          }
      }
  x[v1] = current_x;
  Ebend[RootBrin2.GetEdge()] = Tpoint(x[v1], y[v0]+1);
  }
Example #14
0
inline void
TrsmRUT
( Orientation orientation, UnitOrNonUnit diag,
  F alpha, const DistMatrix<F>& U, DistMatrix<F>& X,
  bool checkIfSingular )
{
#ifndef RELEASE
    PushCallStack("internal::TrsmRUT");
    if( orientation == NORMAL )
        throw std::logic_error("TrsmRUT expects a (Conjugate)Transpose option");
#endif
    const Grid& g = U.Grid();

    // Matrix views
    DistMatrix<F> 
        UTL(g), UTR(g),  U00(g), U01(g), U02(g),
        UBL(g), UBR(g),  U10(g), U11(g), U12(g),
                         U20(g), U21(g), U22(g);

    DistMatrix<F> XL(g), XR(g),
                  X0(g), X1(g), X2(g);

    // Temporary distributions
    DistMatrix<F,VR,  STAR> U01_VR_STAR(g);
    DistMatrix<F,STAR,MR  > U01AdjOrTrans_STAR_MR(g);
    DistMatrix<F,STAR,STAR> U11_STAR_STAR(g);
    DistMatrix<F,VC,  STAR> X1_VC_STAR(g);
    DistMatrix<F,STAR,MC  > X1Trans_STAR_MC(g);
    
    // Start the algorithm
    Scale( alpha, X );
    LockedPartitionUpDiagonal
    ( U, UTL, UTR,
         UBL, UBR, 0 );
    PartitionLeft( X, XL, XR, 0 );
    while( XL.Width() > 0 )
    {
        LockedRepartitionUpDiagonal
        ( UTL, /**/ UTR,  U00, U01, /**/ U02,
               /**/       U10, U11, /**/ U12,
         /*************/ /******************/
          UBL, /**/ UBR,  U20, U21, /**/ U22 );

        RepartitionLeft
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );

        X1_VC_STAR.AlignWith( X0 );
        X1Trans_STAR_MC.AlignWith( X0 );
        U01_VR_STAR.AlignWith( X0 );
        U01AdjOrTrans_STAR_MR.AlignWith( X0 );
        //--------------------------------------------------------------------//
        U11_STAR_STAR = U11;
        X1_VC_STAR = X1; 

        LocalTrsm
        ( RIGHT, UPPER, orientation, diag, 
          F(1), U11_STAR_STAR, X1_VC_STAR, checkIfSingular );

        X1Trans_STAR_MC.TransposeFrom( X1_VC_STAR );
        X1.TransposeFrom( X1Trans_STAR_MC );
        U01_VR_STAR = U01;
        if( orientation == ADJOINT )
            U01AdjOrTrans_STAR_MR.AdjointFrom( U01_VR_STAR );
        else
            U01AdjOrTrans_STAR_MR.TransposeFrom( U01_VR_STAR );

        // X0[MC,MR] -= X1[MC,* ] (U01[MR,* ])^(T/H)
        //            = X1^T[* ,MC] (U01^(T/H))[* ,MR]
        LocalGemm
        ( TRANSPOSE, NORMAL, 
          F(-1), X1Trans_STAR_MC, U01AdjOrTrans_STAR_MR, F(1), X0 );
        //--------------------------------------------------------------------//
        X1_VC_STAR.FreeAlignments();
        X1Trans_STAR_MC.FreeAlignments();
        U01_VR_STAR.FreeAlignments();
        U01AdjOrTrans_STAR_MR.FreeAlignments();

        SlideLockedPartitionUpDiagonal
        ( UTL, /**/ UTR,  U00, /**/ U01, U02,
         /*************/ /******************/
               /**/       U10, /**/ U11, U12, 
          UBL, /**/ UBR,  U20, /**/ U21, U22 );

        SlidePartitionLeft
        ( XL, /**/     XR,
          X0, /**/ X1, X2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
void CEle_Power_DecomposeView::SaveResult()
{
	CMainFrame* pMain=(CMainFrame*)AfxGetApp()->m_pMainWnd;
	pMain->Progress_p = 0;
	pMain->panel_test = "数据存储中。。。";
	pMain->OnPaint();

	CXLEzAutomation XL(FALSE);

	XL.SetCellValue(1,1,"时间");
	XL.SetCellValue(2,1,"功率");

	list<CEleEquitment>::iterator iter = Analyse_Option.Selected_Equit.begin();

	double* CumsumPower = new double[Soluction.EquitNum];
	for(int i = 0;i < Soluction.EquitNum;i++)
	{
		CumsumPower[i] = 0;
	}

	for(int i = 0;iter != Analyse_Option.Selected_Equit.end();i++,iter++)
	{
		XL.SetCellValue(2*i+2,1,(*iter).EquitmentName);
		XL.SetCellValue(2*i+3,1,"累积功率");
	}

	CString str;
	int col = 2;
	for(int i = 0;i < my_result.Result_Length;i++)
	{
		switch(Analyse_Option.TimeMode)
		{
			case ONE_MIN:
			case TEN_MINS:
			case HALF_HOUR:
			case ONE_HOUR:
				XL.SetCellValue(1,i+2,my_result.Power_Result[i].time.Format("%y-%m-%d %H:%M:%S"));
				break;
			case ONE_DAY:
				XL.SetCellValue(1,i+2,my_result.Power_Result[i].time.Format("%y-%m-%d"));
				break;
			case ONE_MONTH:
				XL.SetCellValue(1,i+2,my_result.Power_Result[i].time.Format("%y年%m月"));
				break;
			default:
				break;
		}
		col = 2;
		for (iter = Analyse_Option.Selected_Equit.begin();iter != Analyse_Option.Selected_Equit.end();iter++)
		{
			CumsumPower[(*iter).ID] += my_result.Power_Result[i].Power[(*iter).ID];
			str.Format("%d",int(my_result.Power_Result[i].Power[(*iter).ID]));
			XL.SetCellValue(col,i+2,str);
			col++;

			str.Format("%d",int(CumsumPower[(*iter).ID]));
			XL.SetCellValue(col,i+2,str);
			col++;
		}
		pMain->Progress_p = i*100/my_result.Result_Length;
		str.Format("数据存储中:%d/%d",i+1,my_result.Result_Length);
		pMain->panel_test = str;
		pMain->OnPaint();
	}

	XL.SaveFileAs(Analyse_Option.SavePath);
	XL.ReleaseExcel();
	pMain->Progress_p = 0;
	pMain->panel_test = "数据分析完成";
	pMain->OnPaint();
	AfxMessageBox("分析完毕!!");
}
Example #16
0
inline void
TrsmRLN
( UnitOrNonUnit diag, F alpha, const DistMatrix<F>& L, DistMatrix<F>& X,
  bool checkIfSingular )
{
#ifndef RELEASE
    PushCallStack("internal::TrsmRLN");
#endif
    const Grid& g = L.Grid();

    // Matrix views
    DistMatrix<F> 
        LTL(g), LTR(g),  L00(g), L01(g), L02(g),
        LBL(g), LBR(g),  L10(g), L11(g), L12(g),
                         L20(g), L21(g), L22(g);

    DistMatrix<F> XL(g), XR(g),
                  X0(g), X1(g), X2(g);

    // Temporary distributions
    DistMatrix<F,MR,  STAR> L10Trans_MR_STAR(g);
    DistMatrix<F,STAR,STAR> L11_STAR_STAR(g);
    DistMatrix<F,STAR,MC  > X1Trans_STAR_MC(g);
    DistMatrix<F,VC,  STAR> X1_VC_STAR(g);

    // Start the algorithm
    Scale( alpha, X );
    LockedPartitionUpDiagonal
    ( L, LTL, LTR,
         LBL, LBR, 0 );
    PartitionLeft( X, XL, XR, 0 );
    while( XL.Width() > 0 )
    {
        LockedRepartitionUpDiagonal
        ( LTL, /**/ LTR,  L00, L01, /**/ L02,
               /**/       L10, L11, /**/ L12,
         /*************/ /******************/
          LBL, /**/ LBR,  L20, L21, /**/ L22 );
 
        RepartitionLeft
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );

        X1Trans_STAR_MC.AlignWith( X0 );
        L10Trans_MR_STAR.AlignWith( X0 );
        //--------------------------------------------------------------------//
        L11_STAR_STAR = L11;
        X1_VC_STAR = X1;
        LocalTrsm
        ( RIGHT, LOWER, NORMAL, diag, F(1), L11_STAR_STAR, X1_VC_STAR,
          checkIfSingular );

        // X0[MC,MR] -= X1[MC,* ]   L10[*,MR]
        //            = X1^T[* ,MC] L10^T[MR,* ]
        X1Trans_STAR_MC.TransposeFrom( X1_VC_STAR );
        X1.TransposeFrom( X1Trans_STAR_MC );
        L10Trans_MR_STAR.TransposeFrom( L10 );
        LocalGemm
        ( TRANSPOSE, TRANSPOSE, 
          F(-1), X1Trans_STAR_MC, L10Trans_MR_STAR, F(1), X0 );
        //--------------------------------------------------------------------//
        X1Trans_STAR_MC.FreeAlignments();
        L10Trans_MR_STAR.FreeAlignments();

        SlideLockedPartitionUpDiagonal
        ( LTL, /**/ LTR,  L00, /**/ L01, L02,
         /*************/ /******************/
               /**/       L10, /**/ L11, L12,
          LBL, /**/ LBR,  L20, /**/ L21, L22 );

        SlidePartitionLeft
        ( XL, /**/ XR,
          X0, /**/ X1, X2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
	/*
	
	<iq type=’result’from=’groups.ruijie.com.cn’ to=’[email protected]/pc’>
	<query xmlns=’groups:list’>
	<item id=’112’ name=’吃货群’ icon=”icon_url”v=”false” alert=”1”/>
	<item id=’113’ name=’开心群’ icon=”icon_url”v=”false” alert=”0”/>
	…
	</query>
	</iq>
*/
	void GetGroupsListHandler::handleIqID( const IQ& iq, int context )
	{
		json::jobject jobj;
		if (iq.m_subtype != gloox::IQ::Result)
		{
			const Error* e = iq.error();
			if (!e)
			{
				callback_(true,XL("biz.GetGroupsList.fail"),jobj);
				return;
			}

			if ( e->error() == StanzaErrorBadRequest)
			{
				ELOG("app")->error(WCOOL(L"取群列表时,请求协议错误!。"));
				callback_(true,XL("biz.crwod.iq_error.bad-request"),jobj);
			}
			else if (e->error() == StanzaErrorInternalServerError)
			{
				ELOG("app")->error(WCOOL(L"取群列表时,处理错误(服务器处理错误)。"));
				callback_(true,XL("biz.crwod.iq_error.internal-server-error"),jobj);
			}
			else if (e->error() == StanzaErrorItemNotFound)
			{
				ELOG("app")->error(WCOOL(L"取群列表时,找不到此群。"));
				callback_(true,XL("biz.crwod.iq_error.item-not-found"),jobj);
			}else
			{
				ELOG("app")->error(WCOOL(L"取群列表时,服务器返回未知错误类型!") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
				callback_(true,XL("biz.GetGroupsList.fail"),jobj);
			}

		}else{
			if(iq.findExtension(kExtUser_iq_filter_getgroupslist))
			{
				boost::shared_ptr<gloox::Tag> tag(iq.findExtension(kExtUser_iq_filter_getgroupslist)->tag());
				if (tag)
				{
					//循环取得item
					gloox::TagList items;
					items = tag->findChildren("item");
					TagList::const_iterator it = items.begin();
					for( ; it != items.end(); ++it )
					{
						json::jobject data;
						data["session_id"] = gWrapInterface::instance().append_groups_domain((*it)->findAttribute( "id" ));
						data["remark"] = (*it)->findAttribute( "remark" );
						data["name"] = (*it)->findAttribute( "name" );
						data["icon"]  = (*it)->findAttribute( "icon" );
						data["official"] = (*it)->findAttribute( "v" );
						data["alert"] = (*it)->findAttribute( "alert" );
						data["role"] = (*it)->findAttribute( "role" );
						data["quit"] = (*it)->findAttribute( "quit" );
						data["status"] = (*it)->findAttribute( "status" );
						data["dismiss"] = (*it)->findAttribute( "dismiss" );
						data["active"] = (*it)->findAttribute( "active" );
						data["category"] = (*it)->findAttribute( "category" );
						jobj.arr_push(data);
					}

					if (!callback_.empty())
					{
						callback_(false, XL(""), jobj);
					}

					return;
				}
			}

			ELOG("app")->error(WCOOL(L"取群列表时服务端返回的数据格式错误。") + boost::shared_ptr<gloox::Tag>(iq.tag())->xml());
			if (!callback_.empty())
			{
				universal_resource error_desc;
				error_desc = XL("biz.GetGroupsList.fail");
				callback_(true, error_desc, jobj);
			}
		}
	}
Example #18
0
inline void
TrmmLLTA
( Orientation orientation, 
  UnitOrNonUnit diag,
  T alpha, 
  const DistMatrix<T>& L,
        DistMatrix<T>& X )
{
#ifndef RELEASE
    PushCallStack("internal::TrmmLLTA");
    if( L.Grid() != X.Grid() )
        throw std::logic_error
        ("L and X must be distributed over the same grid");
    if( orientation == NORMAL )
        throw std::logic_error
        ("TrmmLLTA expects a (Conjugate)Transpose option");
    if( L.Height() != L.Width() || L.Height() != X.Height() )
    {
        std::ostringstream msg;
        msg << "Nonconformal TrmmLLTA: \n"
            << "  L ~ " << L.Height() << " x " << L.Width() << "\n"
            << "  X ~ " << X.Height() << " x " << X.Width() << "\n";
        throw std::logic_error( msg.str().c_str() );
    }
#endif
    const Grid& g = L.Grid();

    // Matrix views
    DistMatrix<T> 
        LTL(g), LTR(g),  L00(g), L01(g), L02(g),
        LBL(g), LBR(g),  L10(g), L11(g), L12(g),
                         L20(g), L21(g), L22(g);
    DistMatrix<T>
        XL(g), XR(g),
        X0(g), X1(g), X2(g);

    DistMatrix<T,MC,STAR> X1_MC_STAR(g);
    DistMatrix<T,MR,STAR> Z1_MR_STAR(g);
    DistMatrix<T,MR,MC  > Z1_MR_MC(g);

    X1_MC_STAR.AlignWith( L );
    Z1_MR_STAR.AlignWith( L );

    PartitionRight( X, XL, XR, 0 );
    while( XL.Width() < X.Width() )
    {
        RepartitionRight
        ( XL, /**/ XR,
          X0, /**/ X1, X2 );

        Zeros( X1.Height(), X1.Width(), Z1_MR_STAR );
        //--------------------------------------------------------------------//
        X1_MC_STAR = X1;
        LocalTrmmAccumulateLLT
        ( orientation, diag, alpha, L, X1_MC_STAR, Z1_MR_STAR );

        Z1_MR_MC.SumScatterFrom( Z1_MR_STAR );
        X1 = Z1_MR_MC;
        //--------------------------------------------------------------------//

        SlidePartitionRight
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 );
    }
#ifndef RELEASE
    PopCallStack();
#endif
}
Example #19
0
inline void
TrmmRUNC
( UnitOrNonUnit diag,
  T alpha, const DistMatrix<T>& U,
                 DistMatrix<T>& X )
{
#ifndef RELEASE
    CallStackEntry entry("internal::TrmmRUNC");
    if( U.Grid() != X.Grid() )
        throw std::logic_error
        ("U and X must be distributed over the same grid");
    if( U.Height() != U.Width() || X.Width() != U.Height() )
    {
        std::ostringstream msg;
        msg << "Nonconformal TrmmRUNC: \n"
            << "  U ~ " << U.Height() << " x " << U.Width() << "\n"
            << "  X ~ " << X.Height() << " x " << X.Width() << "\n";
        throw std::logic_error( msg.str().c_str() );
    }
#endif
    const Grid& g = U.Grid();

    // Matrix views
    DistMatrix<T> 
        UTL(g), UTR(g),  U00(g), U01(g), U02(g),
        UBL(g), UBR(g),  U10(g), U11(g), U12(g),
                         U20(g), U21(g), U22(g);

    DistMatrix<T> XL(g), XR(g),
                  X0(g), X1(g), X2(g);

    // Temporary distributions
    DistMatrix<T,MR,  STAR> U12Trans_MR_STAR(g);
    DistMatrix<T,STAR,STAR> U11_STAR_STAR(g);
    DistMatrix<T,VC,  STAR> X1_VC_STAR(g);
    DistMatrix<T,MC,  STAR> X1_MC_STAR(g);
    
    // Start the algorithm
    Scale( alpha, X );
    LockedPartitionUpDiagonal
    ( U, UTL, UTR,
         UBL, UBR, 0 );
    PartitionLeft( X, XL, XR, 0 );
    while( XL.Width() > 0 )
    {
        LockedRepartitionUpDiagonal
        ( UTL, /**/ UTR,  U00, U01, /**/ U02,
               /**/       U10, U11, /**/ U12, 
         /*************/ /******************/
          UBL, /**/ UBR,  U20, U21, /**/ U22 );

        RepartitionLeft
        ( XL,     /**/ XR,
          X0, X1, /**/ X2 ); 

        X1_MC_STAR.AlignWith( X2 );
        U12Trans_MR_STAR.AlignWith( X2 );
        X1_VC_STAR.AlignWith( X1 );
        //--------------------------------------------------------------------//
        X1_MC_STAR = X1;
        U12Trans_MR_STAR.TransposeFrom( U12 );
        LocalGemm
        ( NORMAL, TRANSPOSE, T(1), X1_MC_STAR, U12Trans_MR_STAR, T(1), X2 );

        U11_STAR_STAR = U11;
        X1_VC_STAR = X1_MC_STAR;
        LocalTrmm
        ( RIGHT, UPPER, NORMAL, diag, T(1), U11_STAR_STAR, X1_VC_STAR );
        X1 = X1_VC_STAR;
        //--------------------------------------------------------------------//
        X1_MC_STAR.FreeAlignments();
        U12Trans_MR_STAR.FreeAlignments();
        X1_VC_STAR.FreeAlignments();

        SlideLockedPartitionUpDiagonal
        ( UTL, /**/ UTR,  U00, /**/ U01, U02,
         /*************/ /******************/
               /**/       U10, /**/ U11, U12,
          UBL, /**/ UBR,  U20, /**/ U21, U22 );

        SlidePartitionLeft
        ( XL, /**/ XR,
          X0, /**/ X1, X2 );
    }
}