Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
> Loop over Reducing Matrix Dimensionality
post Feb 29 2016, 05:57 PM
Post #1

Whats this Lie-nix Thing?

Group: Members
Posts: 15
Joined: 22-February 16
Member No.: 19,047

My goal is to take a set of vectors, which run over an index i, and reduce their dimensionality by one for every zero in the array. In particular, I have a set of vectors which have elements

vecA_$i=[ a 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b ]

and I just want to reindex them to have the vector [ a b ]. If I have just one vector, I can do


and this works just fine. However, I am having difficulty doing this over a loop. I attempted to do

for (( i=1; i<=$directory; i++ ))

but this results in a syntax error on the definition line. Can anyone advise how to perform a do loop over a matrix dimensionality reduction?
Go to the top of the page
+Quote Post
Start new topic
post Mar 1 2016, 12:50 PM
Post #2

Its GNU/

Group: Support Specialist
Posts: 1,807
Joined: 23-January 03
Member No.: 360

You have to use indirect like before:
test_1=(a 1 2 3 4 5 6 b)
echo "before" ${test_1[@]}
eval test_${i}="${!dtest[@]:2}"
echo "after" ${test_1[@]}

The string command ${string:0] extracts the entire string so basically nothing happens. The basic command extracts the substring starting at position x. In my code x=2 so the array would then be:
(1 2 3 4 5 6 cool.gif. I don't know if it will work but you can try to use use regular expressions (expr) to extract all zeros.
Go to the top of the page
+Quote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 19th June 2018 - 03:45 AM