void QBluetoothServiceDiscoveryAgentPrivate::startL(const QBluetoothAddress &address)
{
    initL(address);    

    if (uuidFilter.isEmpty()) {
        m_filter->AddL(QBluetoothUuid::PublicBrowseGroup);
    } else {
        foreach (const QBluetoothUuid &uuid, uuidFilter) {
            if (uuid.minimumSize() == 2) {
                TUUID sUuid(uuid.toUInt16());
                m_filter->AddL(sUuid);
            } else if (uuid.minimumSize() == 4) {
                TUUID sUuid(uuid.toUInt32());
                m_filter->AddL(sUuid);
            } else if (uuid.minimumSize() == 16) {
                TUint32 *dataPointer = (TUint32*)uuid.toUInt128().data;
                TUint32 hH = qToBigEndian<quint32>(*(dataPointer++));
                TUint32 hL = qToBigEndian<quint32>(*(dataPointer++));
                TUint32 lH = qToBigEndian<quint32>(*(dataPointer++));
                TUint32 lL = qToBigEndian<quint32>(*(dataPointer));
                TUUID sUuid(hH, hL, lH, lL);
                m_filter->AddL(sUuid);
            } else {
                // filter size can be 0 on error cases, searching all services
                m_filter->AddL(QBluetoothUuid::PublicBrowseGroup);
            }
        }
    }
    m_sdpAgent->SetRecordFilterL(*m_filter);
    m_sdpAgent->NextRecordRequestL();
    qDebug() << "Service discovery started, in startL";
}
Exemple #2
0
int main(){
    int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int z = 10;

    L seq;
    initL(&seq, a, 10);
    printL(&seq);

    printf("binary search %d times is %d\n", z, binarySearch(&seq, z));
}
// ----------------------------------------------------------------------------
// MsgSimNumDetectorPrivate::MsgSimNumDetectorPrivate
// @see MsgSimOperationPrivate_p.h
// ----------------------------------------------------------------------------
MsgSimNumDetectorPrivate::MsgSimNumDetectorPrivate():
mSimOperation(NULL)
{
  QDEBUG_WRITE("MsgSimNumDetectorPrivate::MsgSimNumDetectorPrivate : Enter")
  
  initL();
  
  QDEBUG_WRITE("MsgSimNumDetectorPrivate::MsgSimNumDetectorPrivate : Exit")

}
// ----------------------------------------------------------------------------
// MsgIndicatorPrivate::MsgIndicatorPrivate
// @see MsgIndicatorPrivate.h
// ----------------------------------------------------------------------------
MsgIndicatorPrivate::MsgIndicatorPrivate(MsgIndicator* inidcator) :
    q_ptr(inidcator), mCvServer(NULL)
{
    initL();
}
Exemple #5
0
// Simple row decomposition version;
int LUDecomp_RD(int* argc, char*** argv){

	
	// Declarations
	int i, j, k, p, rank, procs, n, size;
	double **l, **data, *ptrRow;
	double *ldata, *ll, *wdata;

	// Initialization
	MPI_Init(argc, argv);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &procs);


	if(*argc <= 1){
		if(rank == 0)
			printf("Not enough input you stupid ass!\n");
		MPI_Finalize();
		return -1;
	}
	size = atoi((*argv)[1]);
	
	// Initialized a random matrix
	n = size / procs; // suppose divisible;

	init2DArray(&data, n, size);
	randMatrixGene(&data, n, size, rank);

	init2DArray(&l, n, size);
	initL(&l, n, size, rank);
	
    wdata = (double*) malloc(sizeof(double) * size * size);
    ldata = (double*) malloc(sizeof(double) * n * size);
   	MD2SD(&data, &ldata, n, size);
   	
   	MPI_Gather(ldata, n*size, MPI_DOUBLE, wdata, n*size, MPI_DOUBLE, 0, MPI_COMM_WORLD);
   	
	// Parallelized version
	for(k = 0; k < size - 1; k++){
		ptrRow = (double*) malloc(sizeof(double) * (size - k) );
		
		if( k/n == rank){
			p = k%n;
			for(i = k; i < size; i++){
				ptrRow[i-k] = data[p][i]; // spread this information 
			}
		}
		MPI_Bcast(ptrRow, size-k, MPI_DOUBLE, k/n, MPI_COMM_WORLD); // collective call;
		if( fabs((ptrRow[0])) < 0.0001 ){
			MPI_Finalize();
			return -1;
		}
		
		if(k >= n * (rank+1)) continue;

		int cc = (k/n == rank)? (k%n)+1 : 0;

		#pragma omp parallel for
		for(i = cc; i < n; i++){
			l[i][k] = data[i][k] / ptrRow[0];

			for(j = k; j < size; j++){
				data[i][j] -= l[i][k] * ptrRow[j-k];
			}
		}

		free(ptrRow);
	}
	
	// send data back to process 0;
	// MPI_Gather()
	double *U, *L;
	if(rank == 0){
		U = (double*) malloc(sizeof(double) * size * size);
		L = (double*) malloc(sizeof(double) * size * size);
	}

	
	MD2SD(&data, &ldata, n, size);
	ll = (double*) malloc(sizeof(double) * n * size);
	MD2SD(&l, &ll, n, size);

	MPI_Gather(ldata, size*n, MPI_DOUBLE, U, size*n, MPI_DOUBLE, 0, MPI_COMM_WORLD);
	MPI_Gather(ll, size*n, MPI_DOUBLE, L, size*n, MPI_DOUBLE, 0, MPI_COMM_WORLD);

	//free2DArr(data, n, size);
	//free2DArr(l, n, size);
	
	if(rank == 0){
		printf("Whole data:\n");
		for(i = 0; i < size; i++){
			for(j = 0; j< size; j++){
				printf("%lf ", wdata[i*size+j]);
			}
			printf("\n");
		}
		printf("U:\n");
		for(i = 0; i < size; i++){
			for(j = 0; j< size; j++){
				printf("%lf ", U[i*size+j]);
			}
			printf("\n");
		}
		
		printf("L:\n");
		for(i = 0; i < size; i++){
			for(j = 0; j< size; j++){
				printf("%lf ", L[i*size+j]);
			}
			printf("\n");
		}

		matrixPro(L, U, size, size);

		free(U); free(L);
	}

	free(ll); free(ldata);
	
	MPI_Finalize();
	
	return 1;
}