QpBoundData *QpBoundPetsc::makeData( double alpha, Vec g_, Mat Q_, Vec l_, Vec il_, Vec u_, Vec iu_ ) { PetscSpSymMatrixHandle Q( new PetscSpSymMatrix(Q_)); PetscVectorHandle g( new PetscVector(g_) ); PetscVectorHandle l( new PetscVector(l_) ); PetscVectorHandle u( new PetscVector(u_) ); PetscVectorHandle il( new PetscVector(il_) ); PetscVectorHandle iu( new PetscVector(iu_) ); return new QpBoundData( this, alpha, g, Q, l, il, u, iu ); }
static void line(double *x, double *y, /* input (x[i],y[i])s */ double *z, double *w, /* work and output: resid. & fitted */ /* all the above of length */ int n, double coef[2]) { int i, j, k; double xb, x1, x2, xt, yt, yb, tmp1, tmp2; double slope, yint; for(i = 0 ; i < n ; i++) { z[i] = x[i]; w[i] = y[i]; } R_rsort(z, n);/* z = ordered abscissae */ tmp1 = z[il(n, 1./6.)]; tmp2 = z[iu(n, 1./6.)]; xb = 0.5*(tmp1+tmp2); tmp1 = z[il(n, 2./6.)]; tmp2 = z[iu(n, 2./6.)]; x1 = 0.5*(tmp1+tmp2); tmp1 = z[il(n, 4./6.)]; tmp2 = z[iu(n, 4./6.)]; x2 = 0.5*(tmp1+tmp2); tmp1 = z[il(n, 5./6.)]; tmp2 = z[iu(n, 5./6.)]; xt = 0.5*(tmp1+tmp2); slope = 0.; for(j = 1 ; j <= 1 ; j++) { /* yb := Median(y[i]; x[i] <= quantile(x, 1/3) */ k = 0; for(i = 0 ; i < n ; i++) if(x[i] <= x1) z[k++] = w[i]; R_rsort(z, k); yb = 0.5 * (z[il(k, 0.5)] + z[iu(k, 0.5)]); /* yt := Median(y[i]; x[i] >= quantile(x, 2/3) */ k = 0; for(i = 0 ; i < n ; i++) if(x[i] >= x2) z[k++] = w[i]; R_rsort(z,k); yt = 0.5 * (z[il(k, 0.5)] + z[iu(k, 0.5)]); slope += (yt - yb)/(xt - xb); for(i = 0 ; i < n ; i++) { z[i] = y[i] - slope*x[i]; /* never used: w[i] = z[i]; */ } R_rsort(z,n); yint = 0.5 * (z[il(n, 0.5)] + z[iu(n, 0.5)]); } for( i = 0 ; i < n ; i++ ) { w[i] = yint + slope*x[i]; z[i] = y[i] - w[i]; } coef[0] = yint; coef[1] = slope; }
// // Creates a new instance. // void UserAuthProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & myInstance, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::createInstance"); CIMValue userName; CIMValue password; String userNameStr; String passwordStr; String namespaceStr; String authorizationStr; // // get userName // String user; try { const IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } CIMInstance modifiedInst = myInstance; // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (CLASS_NAME_PG_USER.equal (instanceReference.getClassName())) { try { // // Get the user name from the instance // Uint32 pos = myInstance.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)modifiedInst.getProperty(pos); userName = prop.getValue(); userName.get(userNameStr); // // Get the password from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_PASSWORD ); prop = (CIMProperty) modifiedInst.getProperty(pos); password = prop.getValue(); password.get(passwordStr); // // Add the user to the User Manager // _userManager->addUser( userNameStr, passwordStr); } catch ( const CIMException & ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch ( const Exception &e ) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // Get the user name from the instance // Uint32 pos = myInstance.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(userNameStr); // // Get the namespace from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_NAMESPACE ); prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(namespaceStr); // // Get the authorization from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_AUTHORIZATION ); prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(authorizationStr); // // Check if the user is a valid system user // if ( !System::isSystemUser( userNameStr.getCString() ) ) { InvalidSystemUser isu(userNameStr); throw isu; } #ifndef PEGASUS_NO_PASSWORDFILE // // check if the user is a valid CIM user // if ( !_userManager->verifyCIMUser( userNameStr ) ) { InvalidUser iu(userNameStr); throw iu; } #endif _repository->createInstance( instanceReference.getNameSpace(), myInstance); // // set authorization in the UserManager // _userManager->setAuthorization( userNameStr, namespaceStr, authorizationStr ); } catch ( InvalidUser &iu ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, iu.getMessage()); } catch ( InvalidSystemUser &isu ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, isu.getMessage()); } catch ( InvalidNamespace &ins ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, ins.getMessage()); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } catch ( Exception &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION ( CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } handler.deliver(instanceReference); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }