小编Tim*_*Tim的帖子

在bash中的if-condition中使用正则表达式

我想知道在bash的if子句中使用正则表达式的一般规则?

这是一个例子

$ gg=svm-grid-ch  
$ if [[ $gg == *grid* ]] ; then echo $gg; fi  
svm-grid-ch  
$ if [[ $gg == ^....grid* ]] ; then echo $gg; fi  
$ if [[ $gg == ....grid* ]] ; then echo $gg; fi  
$ if [[ $gg == s...grid* ]] ; then echo $gg; fi  
$   
Run Code Online (Sandbox Code Playgroud)

为什么最后三个不匹配?

希望你能尽可能多地给出一般规则,而不仅仅是这个例子.

regex bash

84
推荐指数
5
解决办法
22万
查看次数

R中矩阵的逆

我想知道你推荐的计算矩阵逆的方法是什么?

我发现的方式似乎并不令人满意.例如,

> c=rbind(c(1, -1/4), c(-1/4, 1))  
> c  
      [,1]  [,2]  
[1,]  1.00 -0.25  
[2,] -0.25  1.00  
> inv(c)  
Error: could not find function "inv"  
> solve(c)    
          [,1]      [,2]  
[1,] 1.0666667 0.2666667  
[2,] 0.2666667 1.0666667  
> solve(c)*c  
            [,1]        [,2]  
[1,]  1.06666667 -0.06666667  
[2,] -0.06666667  1.06666667  
> qr.solve(c)*c  
            [,1]        [,2]  
[1,]  1.06666667 -0.06666667  
[2,] -0.06666667  1.06666667  
Run Code Online (Sandbox Code Playgroud)

谢谢!

r matrix-inverse

83
推荐指数
3
解决办法
20万
查看次数

如何匹配不包含单词的行

我想知道如何使用Python风格的Regex匹配不包含特定单词的行(只使用Regex,不涉及Python函数)?

例:

PART ONE OVERVIEW 1 
Chapter 1 Introduction 3
Run Code Online (Sandbox Code Playgroud)

我想匹配不包含单词"PART"的行?

感谢致敬!

regex

80
推荐指数
1
解决办法
9万
查看次数

如何在对齐环境中标记每个方程式?

我想知道如何在对齐环境中标记每个方程?例如

\begin{align} \label{eq:lnnonspbb}
\lambda_i + \mu_i = 0 \\
\mu_i \xi_i = 0 \\
\lambda_i [y_i( w^T x_i + b) - 1 + \xi_i] = 0
\end{align} 
Run Code Online (Sandbox Code Playgroud)

只标记第一个等式,后面只能引用第一个等式.

感谢致敬!

latex equation alignment

71
推荐指数
5
解决办法
14万
查看次数

"gcc -s"和"strip"命令有什么区别?

我想知道这两者有什么区别:

  • gcc -s:从可执行文件中删除所有符号表和重定位信息.

  • strip:丢弃目标文件中的符号.

它们有相同的含义吗?

你用哪一个:

  • 减少可执行文件的大小?
  • 加快运行速度?

gcc symbols strip

66
推荐指数
4
解决办法
7万
查看次数

在awk中选择行和元素

我在awk中了解到,2美元是第2列.如何在第i行和第j列指定第i行和元素?

awk

66
推荐指数
3
解决办法
14万
查看次数

在LaTeX中迭代

我想使用一些迭代控制流来简化以下LaTeX代码.

  \begin{sidewaystable}
  \caption{A glance of images}
  \centering
  \begin{tabular}{| c ||c| c| c |c| c|| c |c| c|c|c| }
  \hline
  \backslashbox{Theme}{Class} &\multicolumn{5}{|c|}{Class 0} & \multicolumn{5}{|c|}{Class 1}  \\
  \hline

  \hline
          1 &
          \includegraphics[scale=2]{../../results/1/0_1.eps}
          &\includegraphics[scale=2]{../../results/1/0_2.eps}
          &\includegraphics[scale=2]{../../results/1/0_3.eps}
          &\includegraphics[scale=2]{../../results/1/0_4.eps}
          &\includegraphics[scale=2]{../../results/1/0_5.eps}
          &\includegraphics[scale=2]{../../results/1/1_1.eps}
          &\includegraphics[scale=2]{../../results/1/1_2.eps}
          &\includegraphics[scale=2]{../../results/1/1_3.eps}
          &\includegraphics[scale=2]{../../results/1/1_4.eps}
          &\includegraphics[scale=2]{../../results/1/1_5.eps}      \\
  \hline

  ...  % similarly for 2, 3, ..., 22

  \hline
          23 &
          \includegraphics[scale=2]{../../results/23/0_1.eps}
          &\includegraphics[scale=2]{../../results/23/0_2.eps}
          &\includegraphics[scale=2]{../../results/23/0_3.eps}
          &\includegraphics[scale=2]{../../results/23/0_4.eps}
          &\includegraphics[scale=2]{../../results/23/0_5.eps}
          &\includegraphics[scale=2]{../../results/23/1_1.eps}
          &\includegraphics[scale=2]{../../results/23/1_2.eps}
          &\includegraphics[scale=2]{../../results/23/1_3.eps}
          &\includegraphics[scale=2]{../../results/23/1_4.eps}
          &\includegraphics[scale=2]{../../results/23/1_5.eps}      \\
  \hline

  \end{tabular}
  \end{sidewaystable}
Run Code Online (Sandbox Code Playgroud)

我了解到forloop包提供了for循环.但我不确定如何将它应用于我的案例?还是其他不通过forloop的方法?


如果我还想要另一个类似的情况,唯一的区别是目录不是从1,2到23运行,而是以某种任意顺序,如3,2,6,9,......,甚至一个字符串列表,如dira,dirc,dird,dirb,....如何将LaTeX代码转换为循环呢?

iteration latex for-loop

58
推荐指数
2
解决办法
8万
查看次数

在Go,CamelCase或Semi-CamelCase中命名函数的方法是什么?

我想在Go中编写一个函数,将文档插入MongoDB数据库的集合中.命名功能的方法更好,

  • writeToMongoDB 要么
  • WriteToMongoD

第二个是CamelCase,虽然我看到有人使用第一个的风格,所以我不确定哪一个更合适.谢谢.

naming-conventions go

58
推荐指数
4
解决办法
4万
查看次数

R中的do-while循环

我想知道如何编写do-while-style循环?

我发现这篇文章:

您可以使用repeat {}并检查使用if()的条件,并使用"break"控制字退出循环.

我不确定它究竟意味着什么.如果你了解它和/或你有不同的解决方案,有人可以详细说明吗?

loops r repeat do-while

56
推荐指数
3
解决办法
14万
查看次数

无法打开共享对象文件:没有这样的文件或目录

我遇到了火炬群集的头节点上找不到的共享库.我已经构建了库以及指定库的正确路径,同时用g ++编译我自己的程序"荒谬".所以我觉得很奇怪.任何的想法?感谢致敬!

[tim@user1 release]$ make  
...  
...  
g++ -pipe -W -Wall -fopenmp -ggdb3 -O2    -I/home/tim/program_files/ICMCluster/ann_1.1.1/include -I/home/tim/program_files/ICMCluster/libsvm-2.89  -I/home/tim/program_files/ICMCluster/svm_light  -o absurdity  xxxxxx.o  -L/home/tim/program_files/ICMCluster/ann_1.1.1/release/lib -L/home/tim/program_files/ICMCluster/libsvm-2.89/release/lib -L/home/tim/program_files/ICMCluster/svm_light/release/lib -lm -ljpeg -lpng -lz -lANN -lpthread -lsvm -lsvmlight  

[tim@user1 release]$ ./absurdity  
./absurdity: error while loading shared libraries: libsvmlight.so: cannot open shared object file: No such file or directory  

[tim@user1 release]$ ls /home/tim/program_files/ICMCluster/svm_light/release/lib/libsvmlight.so -l  
-rwxr-xr-x 1 tim Brown 121407 Jan 31 12:14 /home/tim/program_files/ICMCluster/svm_light/release/lib/libsvmlight.so 

[tim@user1 release]$ LD_LIBRARY_PATH= /home/tim/program_files/ICMCluster/svm_light/release/lib:$LD_LIBRARY_PAT    
[tim@user1 release]$ export LD_LIBRARY_PATH 

[tim@user1 release]$ ./absurdity  
./absurdity: error while loading …
Run Code Online (Sandbox Code Playgroud)

c++

54
推荐指数
4
解决办法
11万
查看次数