text stringlengths 128 2.05k |
|---|
double *dR = 0; status = cublasAlloc(M*N, sizeof(dR), (void**)&dR); if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! device memory allocation error (dR)\n"); return EXIT_FAILURE; |
status = cublasSetMatrix(M, N, sizeof(R), R, M, dR, M); if(status != CUBLAS_STATUS_SUCCESS) fprintf(stderr, "! device access error (write dR)\n"); return EXIT_FAILURE; |
// allocate device memory for T, P double *dT = 0; status = cublasAlloc(M*K, sizeof(dT), (void**)&dT); if(status != CUBLAS_STATUS_SUCCESS) fprintf(stderr, "! device memory allocation error (dT)\n"); return EXIT_FAILURE; |
double *dP = 0; status = cublasAlloc(N*K, sizeof(dP), (void**)&dP); if(status != CUBLAS_STATUS_SUCCESS) fprintf(stderr, "! device memory allocation error (dP)\n"); return EXIT_FAILURE; |
// mean center the data double *dU = 0; status = cublasAlloc(M, sizeof(dU), (void**)&dU); if(status != CUBLAS_STATUS_SUCCESS) fprintf(stderr, "! device memory allocation error (dU)\n"); return EXIT_FAILURE; |
// transfer device dT to host T cublasGetMatrix(M, K, sizeof(dT), dT, M, T, M); // transfer device dP to host P cublasGetMatrix(N, K, sizeof(dP), dP, N, P, N); |
// transfer device dR to host R cublasGetMatrix(M, N, sizeof(dR), dR, M, R, M); // clean up memory status = cublasFree(dP); status = cublasFree(dT); |
status = cublasFree(dR); return EXIT_SUCCESS; int print_results(int M, int N, int K, double *X, double *T, double *P, double *R) int m, n, k; // If M < 13 print the results on screen |
// C/C++ example for the CBLAS (GNU Scientific Library) // implementation of PCA-GS algorithm // // M. Andrecut (c) 2008 // includes, system |
#include <math.h> #include <time.h> // includes, GSL & CBLAS #include <gsl/gsl_vector.h> #include <gsl/gsl_matrix.h> #include <gsl/gsl_blas.h> |
// declarations int gs_pca_gsl(int, int, int, gsl_matrix *, gsl_matrix *, gsl_matrix *); int print_results(int, int, int, gsl_matrix *, gsl_matrix *, gsl_matrix *, gsl_matrix *); |
// output: T, MxK scores matrix // output: P, NxK loads matrix // output: R, MxN residual matrix int M = 1000, m; int N = M/2, n; int K = 10; printf("\nProblem dimensions: MxN=%dx%d, K=%d", M, N, K); |
// initialize srand and clock srand(time(NULL)); clock_t start=clock(); double htime; // initiallize some random test data X gsl_matrix *X = gsl_matrix_alloc (M, N); |
for(m=0; m<M; m++) for(n=0; n<N; n++) gsl_matrix_set(X, m, n, rand()/(double)RAND_MAX); // allocate memory for T, P, R gsl_matrix *T = gsl_matrix_alloc (M, K); |
gsl_matrix *P = gsl_matrix_alloc (N, K); gsl_matrix *R = gsl_matrix_alloc (M, N); htime = ((double)clock()-start)/CLOCKS_PER_SEC; |
printf("\nTime for data allocation: %f\n", htime); // call gs_pca_gsl start=clock(); gsl_matrix_memcpy (R, X); gs_pca_gsl(M, N, K, T, P, R); |
htime = ((double)clock()-start)/CLOCKS_PER_SEC; printf("\n\nTime for GS-PCA host computation: %f\n", htime); // the results are in T, P, R |
printf("\nPress ENTER to exit...\n"); getchar(); return EXIT_SUCCESS; int gs_pca_gsl(int M, int N, int K, gsl_matrix *T, gsl_matrix *P, gsl_matrix *R) // PCA model: X = TLP’ + R |
// input: X, MxN matrix (data, copied in R) // input: M = number of rows in X // input: N = number of columns in X // input: K = number of components (K<=N) |
// output: T, MxK left eigenvectors // output: P, NxK right eigenvectors // output: L, Kx1 eigenvalues // output: R, MxN residual // maximum number of iterations |
int J = 10000; // max error double er = 1.0e-7; double a; int n, k, j; // mean center the data gsl_vector *U = gsl_vector_calloc (M); |
// allocate memory fo eigenvalues gsl_vector *L = gsl_vector_alloc(K); // gs_pca for(k=0; k<K; k++) gsl_blas_dcopy(&gsl_matrix_column(R, k).vector, &gsl_matrix_column(T, k).vector); |
a = 0.0; for(j=0; j<J; j++) gsl_blas_dgemv(CblasTrans, 1.0, R, &gsl_matrix_column(T, k).vector, 0.0, &gsl_matrix_column(P, k).vector);Ψ |
if(k>0) gsl_blas_dgemv(CblasTrans, 1.0, &gsl_matrix_submatrix (P, 0, 0, N, k).matrix, &gsl_matrix_column(P, k).vector, 0.0, &gsl_vector_subvector (U, 0, k).vector); |
gsl_blas_dgemv(CblasNoTrans, -1.0, &gsl_matrix_submatrix (P, 0, 0, N, k).matrix, &gsl_vector_subvector (U, 0, k).vector, 1.0, &gsl_matrix_column(P, k).vector);ΨΨΨΨΨ |
gsl_blas_dscal(1.0/gsl_blas_dnrm2(&gsl_matrix_column(P, k).vector), &gsl_matrix_column(P, k).vector); gsl_blas_dgemv(CblasNoTrans, 1.0, R, &gsl_matrix_column(P, k).vector, 0.0, &gsl_matrix_column(T, k).vector);ΨΨ |
if(k>0) gsl_blas_dgemv(CblasTrans, 1.0, &gsl_matrix_submatrix (T, 0, 0, M, k).matrix, &gsl_matrix_column(T, k).vector, 0.0, &gsl_vector_subvector (U, 0, k).vector); |
gsl_blas_dgemv(CblasNoTrans, -1.0, &gsl_matrix_submatrix (T, 0, 0, M, k).matrix, &gsl_vector_subvector (U, 0, k).vector, 1.0, &gsl_matrix_column(T, k).vector);ΨΨΨΨΨ |
if(fabs(a - gsl_vector_get(L, k)) < er*gsl_vector_get(L, k)) break; a = gsl_vector_get(L, k); gsl_blas_dger (-gsl_vector_get(L, k), &gsl_matrix_column(T, k).vector, &gsl_matrix_column(P, k).vector, R); }ΨΨ |
for(k=0; k<K; k++) gsl_blas_dscal (gsl_vector_get(L, k), &gsl_matrix_column(T, k).vector); // memory clean up gsl_vector_free(L); |
gsl_vector_free(U); return EXIT_SUCCESS; int print_results(int M, int N, int K, gsl_matrix *X, gsl_matrix *T, gsl_matrix *P, gsl_matrix *R) Ψint m, n; |
/* If M < 13 print the results on screen */Ψ if(M > 12) return EXIT_SUCCESS; printf("\nX\n"); for(m=0; m<M; m++) for(n=0; n<N; n++) printf("%+f ", gsl_matrix_get(X, m, n)); printf("\n"); |
return EXIT_SUCCESS; Appendix 4: gs_pca.c // C/C++ example for the CUBLAS (NVIDIA) // implementation of PCA-GS algorithm // // M. Andrecut (c) 2008 |
// matrix indexing convention #define id(m, n, ld) (((n) * (ld) + (m))) // declarations int gs_pca_cublas(int, int, int, double *, double *, double *); |
int print_results(int, int, int, double *, double *, double *, double *); // main int main(int argc, char** argv) // PCA model: X = TP’ + R |
// initialize srand and clock srand (time(NULL)); clock_t start=clock(); double dtime; // initialize cublas cublasStatus status; |
status = cublasInit(); if(status != CUBLAS_STATUS_SUCCESS) fprintf(stderr, "! CUBLAS initialization error\n"); return EXIT_FAILURE; |
// initiallize some random test data X double *X; X = (double*)malloc(M*N * sizeof(X)); if(X == 0) fprintf (stderr, "! host memory allocation error: X\n"); return EXIT_FAILURE; |
R = (double*)malloc(M*N * sizeof(R));; if(R == 0) fprintf(stderr, "! host memory allocation error: R\n"); return EXIT_FAILURE; ΨΨΨ dtime = ((double)clock()-start)/CLOCKS_PER_SEC; |
printf("\nTime for data allocation: %f\n", dtime); // call gs_pca_cublas start=clock(); memcpy(R, X, M*N * sizeof(X)); gs_pca_cublas(M, N, K, T, P, R); |
dtime = ((double)clock()-start)/CLOCKS_PER_SEC; printf("\nTime for device GS-PCA computation: %f\n", dtime); // the results are in T, P, R |
print_results(M, N, K, X, T, P, R); // clean up memory free(P); Ψ free(T); free(X); // shutdown status = cublasShutdown(); if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! cublas shutdown error\n"); return EXIT_FAILURE; |
if(argc <= 1 || strcmp(argv, "-noprompt")) printf("\nPress ENTER to exit...\n"); getchar(); return EXIT_SUCCESS; int gs_pca_cublas(int M, int N, int K, double *T, double *P, double *R) // PCA model: X = TP’ + R |
// output: T, MxK scores matrix // output: P, NxK loads matrix // output: R, MxN residual matrix cublasStatus status; // maximum number of iterations |
int J = 10000; // max error double er = 1.0e-7; int n, j, k; // transfer the host matrix X to device matrix dR double *dR = 0; status = cublasAlloc(M*N, sizeof(dR), (void**)&dR); |
if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! device memory allocation error (dR)\n"); return EXIT_FAILURE; status = cublasSetMatrix(M, N, sizeof(R), R, M, dR, M); |
if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! device access error (write dR)\n"); return EXIT_FAILURE; // allocate device memory for T, P |
double *dT = 0; status = cublasAlloc(M*K, sizeof(dT), (void**)&dT); if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! device memory allocation error (dT)\n"); return EXIT_FAILURE; |
double *dP = 0; status = cublasAlloc(N*K, sizeof(dP), (void**)&dP); if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! device memory allocation error (dP)\n"); return EXIT_FAILURE; |
// allocate memory for eigenvalues double *L; L = (double*)malloc(K * sizeof(L));; if(L == 0) fprintf (stderr, "! host memory allocation error: T\n"); return EXIT_FAILURE; |
// mean center the data double *dU = 0; status = cublasAlloc(M, sizeof(dU), (void**)&dU); if(status != CUBLAS_STATUS_SUCCESS) fprintf (stderr, "! device memory allocation error (dU)\n"); return EXIT_FAILURE; |
cublasGetMatrix (M, K, sizeof(dT), dT, M, T, M); // transfer device dP to host P cublasGetMatrix (N, K, sizeof(dP), dP, N, P, N); |
// transfer device dR to host R cublasGetMatrix (M, N, sizeof(dR), dR, M, R, M); // clean up memory free(L); status = cublasFree(dP); |
status = cublasFree(dT); status = cublasFree(dR); return EXIT_SUCCESS; int print_results(int M, int N, int K, double *X, double *T, double *P, double *R) int m, n, k; // If M < 13 print the results on screen |
# Source: arxiv 0811.2791 # Title: Effects of multiple occupancy and inter-particle interactions on selective transport through narrow channels: theory versus experiment # Sections: all # Downloaded: 2026-03-03T05:14:05.715622+00:00 |
Effects of multiple occupancy and inter-particle interactions on selective transport through narrow channels: theory versus experiment |
Abstract Many biological and artificial transport channels function without direct input of metabolic energy during a transport event and without structural rearrangements involving transitions from a ’closed’ to an ’open’ state. Nevertheless, such channels are able to maintain efficient and selective transport. It has... |
Key words: Transport; Channels; Selectivity; Efficiency; Diffusion; Occupancy Introduction The proper functioning of living cells involves continuous transport of various molecules into and out of the cell, as well as between different cell compartments. Such transport requires discrimination between different intra- a... |
In certain cases, the selectivity and efficiency of the transport is achieved through direct input of metabolic energy during the transport event, in the form of the hydrolysis of ATP or GTP . However, in many cases, molecular transport is efficient and selective without the direct input of the metabolic energy and wit... |
Transport devices of this type commonly contain a channel or a passageway through which the molecules translocate by facilitated diffusion. The selectivity and the efficiency of transport are usually based not merely on the molecule size but on a combination of the size, strength of the interaction with the channel, sp... |
Understanding mechanisms of the selectivity of transport through such channels is an important biological question and also has important applications in nano-technology and nano-medicine. For instance, it impacts creation of artificial molecular nano-filters. In addition, it poses a fundamental physical question: how ... |
The precise mechanisms and the conditions for optimal selectivity of transport through such channels are still unknown. These systems span a wide spectrum of space and time scales and biological functions. For instance, porins are involved in the transport of small molecules into and out of the cell. They typically hav... |
Nevertheless, it has been suggested that such channels might share common mechanisms of selectivity and efficiency. Recent theoretical works propose a mechanism of selectivity that relies on two crucial factors, transient trapping of the cargoes inside the pore and the resulting confinement of the cargoes in the limite... |
However, space inside the channel is limited, and if the molecules spend too much time inside the channel, they prevent entrance of new ones. The channel thus becomes jammed and the transport is diminished. To model the jamming of the channel, the authors of 34 30 35 27 33 assumed that additional molecules cannot enter... |
However, during transport, the channel can be occupied by multiple molecules, which cannot bypass each other, or do so only in the limited fashion, due to the confinement in the limited space inside the channel 51 48 47 45 49 50 . The transport is not necessarily single-file: the number of molecules that can be present... |
Understanding the effects of multiple channel occupancy and jamming on the transport selectivity is especially pertinent to the analysis of single molecule tracking experiments 58 57 59 and the design of artificial nano-molecular filters 13 16 14 19 15 17 18 |
In this paper, we analyze transport through narrow channels in a framework of a general kinetic model based on exclusion process theory as a function of the kinetic parameters of transport Specifically, we examine the rates of entrance, hopping through and exit from the channel. We extend the previous work to include m... |
The paper is organized as follows. We first discuss a channel that consists only of one ’site’ and then two-sites. Next, we discuss transport in a uniform symmetric channel of arbitrary length, for both single-file and non-single-file transport, and establish conditions for optimal transport. We then discuss the transi... |
Inter-particle interactions inside the channel A transport channel can be represented as a chain of positions (sites), as illustrated in Figs. 1 and 2 51 42 35 29 27 48 49 47 50 The particles attempt to enter the channel at a given position, with an average rate [MATH] and subsequently hop back and forth between adjace... |
As the particles accumulate in the limited space inside the channel, they start to interfere with the movement of the neighboring particles and prevent the entrance of new ones. We must differentiate between the speed, the efficiency, and the probability of transport. The speed is determined by the time the particles s... |
2.1 One site channel To get started, let us consider a ’one-site’ channel 27 42 , where all the internal spatial and energetic structure of the channel is absorbed into the forward and the backward exit rates [MATH] [MATH] |
Kinetic diagram of such a ’one-site’ channel is shown in Fig. 1 . The state of the channel is specified by the particle density ( [MATH] ) at the channel site (or, in other words, the probability of the channel to be occupied). It obeys the following kinetic equation 42 27 |
[EQUATION] which takes into account that the particles can enter the channel only if it is not occupied. The average time a particle spends inside the channel is [MATH] |
27 42 At steady state ( [MATH] ) we get for the average density and the forward flux: [EQUATION] As mentioned above, we define the transport efficiency as the ratio of the transmitted flux to the entering flux, [MATH] . Thus, from the equation ( ) we learn that the transport efficiency [MATH] is a monotonic function of... |
2.2 Two site channel Let us consider now a longer channel consisting of two sites: 1 and 2. This is the shortest channel that explicitly takes into account the asymmetry between the channel entrance and exit, and exhibits non-trivial transport properties 27 34 49 33 . The kinetics of transport through such a channel is... |
The state of the channel is characterized by the average occupancies of the sites, [MATH] and [MATH] . For an internally uniform channel, these average occupancies can also be viewed as the probabilities that the sites [MATH] and [MATH] are occupied by a particle 45 47 . The kinetic equations describing transport throu... |
[EQUATION] and the transmitted flux is [MATH] The transport efficiency [MATH] is the fraction of the flux [MATH] that exits the channel to the right. Solving equations ( ) at steady state ( [MATH] , one gets for the transport efficiency: |
[EQUATION] Importantly, unlike in the one-site case, for a given entrance flux [MATH] , the transport efficiency [MATH] has a maximum at a certain value of the exit rate [MATH] . This provides a mechanism of selectivity; only particles whose residence time in the channel (determined by the interactions of the particles... |
The total efficiency [MATH] is influenced by two different effects, the jamming of the channel entrance and the mutual interference between the particles inside the channel. The flux that actually enters the channel is [MATH] . The remaining portion of the flux, [MATH] , does not enter the channel because the entrance ... |
[MATH] , which characterizes transport through the channel. From the equations ( [EQUATION] Very importantly, [MATH] is independent of the flux [MATH] and is equal to the efficiency in the single-particle limit, [MATH] . That is, it is equivalent to the probability of a single particle to translocate through the channe... |
To summarize this section, selective transport can arise from a balance between two competing effects, enhancement of the transport by the transient trapping and the eventual jamming of the channel if the trapping times are too high 33 27 30 48 29 |
2.3 Channel of arbitrary number of sites In this section we study transport through a channel of arbitrary length, which is modeled as a chain of [MATH] positions (sites): 1, 2…i…N . Particles enter at site [MATH] (not necessarily the leftmost one) with an average flux [MATH] if the entrance site is not fully occupied.... |
42 27 32 41 Trapping of the particles in the channel corresponds to low exit rates [MATH] 42 33 27 43 For simplicity, we assume that the channel is internally uniform, such that all the internal transition rates are equal, |
[MATH] for all [MATH] . At any time [MATH] , the state of the channel is specified by the number densities of the particles at each site [MATH] . The kinetics of transport through such a channel is described by the following equations 47 49 50 48 42 |
[EQUATION] with the boundary conditions at sites [MATH] and [MATH] [EQUATION] where the [MATH] -function is [MATH] and zero otherwise. The terms [MATH] in equations ( ) and ( 2.3 ) reflect the fact that a particle can jump to the next site only if it is not fully occupied, [MATH] . Importantly, for an internally unifor... |
We define the efficiency of transport as the ratio of the forward exit current [MATH] to the incoming flux [MATH] [MATH] . It is the fraction of the incoming flux that traverses the channel. Note that the efficiency is different from the probability of individual particles to traverse the channel after they have entere... |
The linear equations ( ),( 2.3 ) can be solved analytically for any [MATH] 48 In the fully symmetric case, when the forward and the backward exit rates from sites [MATH] and [MATH] are equal, [MATH] , the efficiency is given by: |
[EQUATION] (for [MATH] ). Note that in the single particle diffusion limit, [MATH] , the efficiency [MATH] without trapping ( [MATH] ) and [MATH] for strong trapping ( [MATH] ), in accord with known results 27 26 29 42 55 41 48 . Essentially, without transient trapping, the probability to traverse the channel is low an... |
One may rewrite equation ( ) in terms of the trapping time, which is equal to [MATH] 52 43 27 to arrive at [EQUATION] where [MATH] is the normalized flux. Note that the transport efficiency does not depend on the absolute values of the transport rates [MATH] and [MATH] , but only on the normalized parameters [MATH] and... |
As already seen in the two-site case, the transport efficiency [MATH] of equation ( ) has a maximum at a certain value of the exit rate (for [MATH] ) of |
[EQUATION] and the maximal flux at this rate is [EQUATION] (cf. Appendix for [MATH] ). This feature provides a mechanism of selectivity; only the particles whose exit rate is close to the optimal one, [MATH] , are transmitted efficiently. Particles with exit rates higher than the optimal have a higher chance of returni... |
Equations ( ) and ( 10 ) qualitatively agree with the results of 35 34 30 33 , which assumed that only one molecule can occupy the channel. Figure 3 shows how the transport depends on the channel length [MATH] , the entrance flux [MATH] , the exit rate [MATH] and the effective channel width [MATH] . Note that the optim... |
2.4 Transport efficiency vs. translocation probability In this section, we elaborate on why the flux through the channel decreases in the limit of very low exit rates? Is this because new particles cannot enter or because the particles inside the channel interfere with each other’s passage? |
The fraction of the incoming flux [MATH] that actually enters the channel is [MATH] . The remaining portion of the flux [MATH] cannot enter because the entrance site is occupied on average [MATH] fraction of the time (cf. Sec. 4 for calculation of the densities). The total efficiency is determined by two quantities: i)... |
[MATH] of a particle exiting to the right after it has entered the channel and is given by [EQUATION] Remarkably, it is independent of the flux [MATH] and is exactly equal to the efficiency in the single particle transport limit, [MATH] . This means that in unform channels the interactions between the particles in the ... |
Optimal transport and jamming The lower the exit rate [MATH] , the longer the time that the particles spend inside the channel. The trapping time varies as [MATH] |
52 43 27 . As shown in the previous section, at very small exit rates [MATH] , the trapping time is so high that the channel becomes jammed. Thus, the transport efficiency is maximized at the particular exit rate [MATH] . Inspection of the Fig. 3 reveals two distinct transport regimes, roughly separated by the maximum ... |
Solving equations ( ) and ( 2.3 ), we get for the density profile of the particles inside the channel, at the steady state: [EQUATION] |
(for [MATH] [MATH] ). Note that unlike the equilibrium distribution, the maximum of the density profile is near the channel entrance at site [MATH] |
The total number of the particles in the channel is [EQUATION] Note that in the limit [MATH] [MATH] . That is, the particles accumulate and never leave the channel. Therefore, from equation ( 14 ) one finds that at the point of the jamming transition, [MATH] , the number of the particles in the channel is |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.