Symbolic array pre-allocation
    11 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
    lvn
      
 le 28 Oct 2014
  
    
    
    
    
    Réponse apportée : Stefan Wehmeier
    
 le 30 Oct 2014
            Symbolic array pre-allocation only allocates pointers as I understood it from reading the forum. This is causing a major slowdown in code we are looking at
a=sym(zeros(50000,1));
Filling the area with relatively simple expression e.g. '3+sqrt(5)/sqrt(7)' a serious slowdown is noted around the 9000th index.
Would it be possible to allocate memory by defining the sym array (in the definition) with large expressions '3+sqrt(1)+sqrt(2)+sqrt(3)+sqrt(4)+sqrt(5)+sqrt(6)+sqrt(7)' for all elements 1:50000, so that effectively a memory allocation is forced at the definition step. Is this possible in the definition of sym? I tried repmat, but didn't get it too work.
2 commentaires
  Siddharth Sundar
    
 le 29 Oct 2014
				- Can you check the output of the memory command before and after the 9000th iteration of the for loop you are to define these expressions? - What is the expression you are using in the 9000th iteration?
Réponse acceptée
  Stefan Wehmeier
    
 le 30 Oct 2014
        My question is in which form do you have the 50000 entries you want to fill in. As strings in a cell array A? Then
B = cellfun(@sym, A, 'UniformOutput', false);
list1 = [B{:}];
is better. Or really 50000 times the same string? Then avoid calling sym(..) on it in a loop.
All sym vectors are internally vectors of pointers. You cannot pre-allocate the memory these pointers point to ...
0 commentaires
Plus de réponses (0)
Voir également
Catégories
				En savoir plus sur Logical dans Help Center et File Exchange
			
	Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


