<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Le 21/12/2012 11:46, phil_shvarcz a
écrit :<br>
</div>
<blockquote cite="mid:1356086772771-4025574.post@n3.nabble.com"
type="cite">
<pre wrap="">Hi all,
being new to scilab I'm not sure if my problem has a trivial solution or
not. I searched all documentation and forum postings but did not find
anything relevant for my problem. So that's it:
I need to read in quite big binary files (several 100MB) composed of
successive pairs of float (4 byte word) and double (8 byte word). That is,
the byte sequence looks like this ("ffff" is a 4-byte float and "dddddddd"
is an 8 byte double):
ffffddddddddffffddddddddffffddddddddffffdddddd
if I use this code:</pre>
</blockquote>
You forgot it?<br>
<blockquote cite="mid:1356086772771-4025574.post@n3.nabble.com"
type="cite">
<pre wrap="">
the file is read in at an incredibly slow rate (a few MB take minutes to be
read in).
If I read in the entire file in one flush
it takes a second or so to read in 100MB. However, the data structure is
lost and the vector vb contains nonsensical doubles.
Is there a way in scilab to read in a (structureless) vector of bytes and
cast it to the right structure afterwards, like one would do with an array
in C ?</pre>
</blockquote>
I do not think so.<br>
<blockquote cite="mid:1356086772771-4025574.post@n3.nabble.com"
type="cite">
<pre wrap="">
Besides, is it normal that mread is *so* slow when used to read a file in a
word-by-word manner instead of reading it in one big chunk?</pre>
</blockquote>
I do not know the mread function. Whre do you find it?<br>
<br>
Any way it is normal that a word_by-word read being slower because
on each iteration the program as to check if the arguments are ok or
not, the system as to create an interrupt , ...<br>
<br>
May be you can use a code similar to the one below to be able to
read your file. It is bit tricky because it needs to create an
intermediate file<br>
<br>
<br>
<br>
suppose your file is named yourfile and contains N floatting point
numbers<br>
<br>
<br>
<font color="#000099">//read all the numbers in the file assumming
float format</font><br>
<font color="#000099">u=mopen('yourfile','r');<br>
T=mget(3*N,'f',u);<br>
F=T(1:3:$); // the float numbers<br>
mclose(u);<br>
//now write down all the records corresponding to doubles<br>
I=(2:3)'.*.ones(1,N/2)+(0:3:3*N-3).*.ones(2,1);<br>
u=mopen('/tmp/foo','w')<br>
mput(T(I),'f',u);<br>
mclose(u);<br>
//read it again as double<br>
u=mopen('/tmp/foo','r');<br>
D=mget(N,'d',u);<br>
mclose(u)</font>;<br>
<br>
<br>
Serge Steer<br>
<blockquote cite="mid:1356086772771-4025574.post@n3.nabble.com"
type="cite">
<pre wrap="">
Thanks for reading,
regards
Phil
--
View this message in context: <a class="moz-txt-link-freetext" href="http://mailinglists.scilab.org/Performance-issue-with-mget-on-inhomogeneous-binary-file-tp4025574.html">http://mailinglists.scilab.org/Performance-issue-with-mget-on-inhomogeneous-binary-file-tp4025574.html</a>
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
</body>
</html>