File: intro.html

package info (click to toggle)
slepc 3.24.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 122,028 kB
  • sloc: ansic: 104,353; javascript: 12,732; python: 5,958; f90: 3,312; cpp: 1,528; makefile: 761; xml: 679; sh: 347
file content (1046 lines) | stat: -rw-r--r-- 113,848 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046

<!DOCTYPE html>


<html lang="en" data-content_root="../../" >

  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Getting Started &#8212; SLEPc 3.24.1 documentation</title>
  
  
  
  <script data-cfasync="false">
    document.documentElement.dataset.mode = localStorage.getItem("mode") || "";
    document.documentElement.dataset.theme = localStorage.getItem("theme") || "";
  </script>
  <!--
    this give us a css class that will be invisible only if js is disabled
  -->
  <noscript>
    <style>
      .pst-js-only { display: none !important; }

    </style>
  </noscript>
  
  <!-- Loaded before other Sphinx assets -->
  <link href="../../_static/styles/theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />
<link href="../../_static/styles/pydata-sphinx-theme.css?digest=8878045cc6db502f8baf" rel="stylesheet" />

    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=8f2a1f02" />
    <link rel="stylesheet" type="text/css" href="../../_static/copybutton.css?v=76b2166b" />
    <link rel="stylesheet" type="text/css" href="../../_static/togglebutton.css?v=13237357" />
    <link rel="stylesheet" type="text/css" href="../../_static/sphinx-design.min.css?v=95c83b7e" />
    <link rel="stylesheet" type="text/css" href="../../_static/css/slepc.css?v=d285b177" />
  
  <!-- So that users can add custom icons -->
  <script src="../../_static/scripts/fontawesome.js?digest=8878045cc6db502f8baf"></script>
  <!-- Pre-loaded scripts that we'll load fully later -->
  <link rel="preload" as="script" href="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf" />
<link rel="preload" as="script" href="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf" />

    <script src="../../_static/documentation_options.js?v=d1c46438"></script>
    <script src="../../_static/doctools.js?v=9a2dae69"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="../../_static/clipboard.min.js?v=a7894cd8"></script>
    <script src="../../_static/copybutton.js?v=a56c686a"></script>
    <script>let toggleHintShow = 'Click to show';</script>
    <script>let toggleHintHide = 'Click to hide';</script>
    <script>let toggleOpenOnPrint = 'true';</script>
    <script src="../../_static/togglebutton.js?v=4a39c7ea"></script>
    <script src="../../_static/design-tabs.js?v=f930bc37"></script>
    <script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
    <script>var togglebuttonSelector = '.toggle, .admonition.dropdown';</script>
    <script>window.MathJax = {"options": {"processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
    <script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
    <script>DOCUMENTATION_OPTIONS.pagename = 'documentation/manual/intro';</script>
    <link rel="icon" href="../../_static/favicon-slepc.ico"/>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="EPS: Eigenvalue Problem Solver" href="eps.html" />
    <link rel="prev" title="SLEPc Users Manual" href="index.html" />
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
  <meta name="docsearch:language" content="en"/>
  <meta name="docsearch:version" content="3.24" />
  </head>
  
  
  <body data-bs-spy="scroll" data-bs-target=".bd-toc-nav" data-offset="180" data-bs-root-margin="0px 0px -60%" data-default-mode="">

  
  
  <div id="pst-skip-link" class="skip-link d-print-none"><a href="#main-content">Skip to main content</a></div>
  
  <div id="pst-scroll-pixel-helper"></div>
  
  <button type="button" class="btn rounded-pill" id="pst-back-to-top">
    <i class="fa-solid fa-arrow-up"></i>Back to top</button>

  
  <dialog id="pst-search-dialog">
    
<form class="bd-search d-flex align-items-center"
      action="../../search.html"
      method="get">
  <i class="fa-solid fa-magnifying-glass"></i>
  <input type="search"
         class="form-control"
         name="q"
         placeholder="Search the docs ..."
         aria-label="Search the docs ..."
         autocomplete="off"
         autocorrect="off"
         autocapitalize="off"
         spellcheck="false"/>
  <span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form>
  </dialog>

  <div class="pst-async-banner-revealer d-none">
  <aside id="bd-header-version-warning" class="d-none d-print-none" aria-label="Version warning"></aside>
</div>

  
    <header class="bd-header navbar navbar-expand-lg bd-navbar d-print-none">
<div class="bd-header__inner bd-page-width">
  <button class="pst-navbar-icon sidebar-toggle primary-toggle" aria-label="Site navigation">
    <span class="fa-solid fa-bars"></span>
  </button>
  
  
  <div class="col-lg-3 navbar-header-items__start">
    
      <div class="navbar-item">

  
    
  

<a class="navbar-brand logo" href="../../index.html">
  
  
  
  
  
    
    
      
    
    
    <img src="../../_static/logo-slepc.gif" class="logo__image only-light" alt="SLEPc Home"/>
    <img src="../../_static/logo-slepc.gif" class="logo__image only-dark pst-js-only" alt="SLEPc Home"/>
  
  
</a></div>
    
  </div>
  
  <div class="col-lg-9 navbar-header-items">
    
    <div class="me-auto navbar-header-items__center">
      
        <div class="navbar-item">
<nav>
  <ul class="bd-navbar-elements navbar-nav">
    
<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../about/index.html">
    About
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../installation/index.html">
    Installation
  </a>
</li>


<li class="nav-item current active">
  <a class="nav-link nav-internal" href="../index.html">
    Documentation
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../manualpages/index.html">
    C/Fortran API
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../slepc4py/index.html">
    slepc4py API
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../material/index.html">
    Material
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../contact/index.html">
    Contact
  </a>
</li>

  </ul>
</nav></div>
      
    </div>
    
    
    <div class="navbar-header-items__end">
      
        <div class="navbar-item navbar-persistent--container">
          

<button class="btn search-button-field search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
 <i class="fa-solid fa-magnifying-glass"></i>
 <span class="search-button__default-text">Search</span>
 <span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
        </div>
      
      
        <div class="navbar-item">

<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode"  data-bs-placement="bottom" data-bs-toggle="tooltip">
  <i class="theme-switch fa-solid fa-sun                fa-lg" data-mode="light" title="Light"></i>
  <i class="theme-switch fa-solid fa-moon               fa-lg" data-mode="dark"  title="Dark"></i>
  <i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto"  title="System Settings"></i>
</button></div>
      
        <div class="navbar-item"><ul class="navbar-icon-links"
    aria-label="Icon Links">
        <li class="nav-item">
          
          
          
          
          
          
          
          
          <a href="https://gitlab.com/slepc/slepc" title="GitLab" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-square-gitlab fa-lg" aria-hidden="true"></i>
            <span class="sr-only">GitLab</span></a>
        </li>
        <li class="nav-item">
          
          
          
          
          
          
          
          
          <a href="https://www.upv.es" title="UPV" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><img src="https://www.upv.es/favicon.ico" class="icon-link-image" alt="UPV"/></a>
        </li>
        <li class="nav-item">
          
          
          
          
          
          
          
          
          <a href="https://slepc.upv.es/release/_static/rss/slepc-news.xml" title="Feed" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-solid fa-square-rss fa-lg" aria-hidden="true"></i>
            <span class="sr-only">Feed</span></a>
        </li>
</ul></div>
      
    </div>
    
  </div>
  
  
    <div class="navbar-persistent--mobile">

<button class="btn search-button-field search-button__button pst-js-only" title="Search" aria-label="Search" data-bs-placement="bottom" data-bs-toggle="tooltip">
 <i class="fa-solid fa-magnifying-glass"></i>
 <span class="search-button__default-text">Search</span>
 <span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd class="kbd-shortcut__modifier">K</kbd></span>
</button>
    </div>
  

  
    <button class="pst-navbar-icon sidebar-toggle secondary-toggle" aria-label="On this page">
      <span class="fa-solid fa-outdent"></span>
    </button>
  
</div>

    </header>
  

  <div class="bd-container">
    <div class="bd-container__inner bd-page-width">
      
      
      
      <dialog id="pst-primary-sidebar-modal"></dialog>
      <div id="pst-primary-sidebar" class="bd-sidebar-primary bd-sidebar">
        

  
  <div class="sidebar-header-items sidebar-primary__section">
    
    
      <div class="sidebar-header-items__center">
        
          
          
            <div class="navbar-item">
<nav>
  <ul class="bd-navbar-elements navbar-nav">
    
<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../about/index.html">
    About
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../installation/index.html">
    Installation
  </a>
</li>


<li class="nav-item current active">
  <a class="nav-link nav-internal" href="../index.html">
    Documentation
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../manualpages/index.html">
    C/Fortran API
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../slepc4py/index.html">
    slepc4py API
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../material/index.html">
    Material
  </a>
</li>


<li class="nav-item ">
  <a class="nav-link nav-internal" href="../../contact/index.html">
    Contact
  </a>
</li>

  </ul>
</nav></div>
          
        
      </div>
    
    
    
      <div class="sidebar-header-items__end">
        
          <div class="navbar-item">

<button class="btn btn-sm nav-link pst-navbar-icon theme-switch-button pst-js-only" aria-label="Color mode" data-bs-title="Color mode"  data-bs-placement="bottom" data-bs-toggle="tooltip">
  <i class="theme-switch fa-solid fa-sun                fa-lg" data-mode="light" title="Light"></i>
  <i class="theme-switch fa-solid fa-moon               fa-lg" data-mode="dark"  title="Dark"></i>
  <i class="theme-switch fa-solid fa-circle-half-stroke fa-lg" data-mode="auto"  title="System Settings"></i>
</button></div>
        
          <div class="navbar-item"><ul class="navbar-icon-links"
    aria-label="Icon Links">
        <li class="nav-item">
          
          
          
          
          
          
          
          
          <a href="https://gitlab.com/slepc/slepc" title="GitLab" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-brands fa-square-gitlab fa-lg" aria-hidden="true"></i>
            <span class="sr-only">GitLab</span></a>
        </li>
        <li class="nav-item">
          
          
          
          
          
          
          
          
          <a href="https://www.upv.es" title="UPV" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><img src="https://www.upv.es/favicon.ico" class="icon-link-image" alt="UPV"/></a>
        </li>
        <li class="nav-item">
          
          
          
          
          
          
          
          
          <a href="https://slepc.upv.es/release/_static/rss/slepc-news.xml" title="Feed" class="nav-link pst-navbar-icon" rel="noopener" target="_blank" data-bs-toggle="tooltip" data-bs-placement="bottom"><i class="fa-solid fa-square-rss fa-lg" aria-hidden="true"></i>
            <span class="sr-only">Feed</span></a>
        </li>
</ul></div>
        
      </div>
    
  </div>
  
    <div class="sidebar-primary-items__start sidebar-primary__section">
        <div class="sidebar-primary-item">
<nav class="bd-docs-nav bd-links"
     aria-label="Section Navigation">
  <p class="bd-links__title" role="heading" aria-level="1">Section Navigation</p>
  <div class="bd-toc-item navbar-nav"><ul class="current nav bd-sidenav">
<li class="toctree-l1 current active has-children"><a class="reference internal" href="index.html">SLEPc Users Manual</a><details open="open"><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul class="current">
<li class="toctree-l2 current active"><a class="current reference internal" href="#">Getting Started</a></li>
<li class="toctree-l2"><a class="reference internal" href="eps.html">EPS: Eigenvalue Problem Solver</a></li>
<li class="toctree-l2"><a class="reference internal" href="st.html">ST: Spectral Transformation</a></li>
<li class="toctree-l2"><a class="reference internal" href="svd.html">SVD: Singular Value Decomposition</a></li>
<li class="toctree-l2"><a class="reference internal" href="pep.html">PEP: Polynomial Eigenvalue Problems</a></li>
<li class="toctree-l2"><a class="reference internal" href="nep.html">NEP: Nonlinear Eigenvalue Problems</a></li>
<li class="toctree-l2"><a class="reference internal" href="mfn.html">MFN: Matrix Function</a></li>
<li class="toctree-l2"><a class="reference internal" href="lme.html">LME: Linear Matrix Equation</a></li>
<li class="toctree-l2"><a class="reference internal" href="aux.html">Auxiliary Classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="extra.html">Additional Information</a></li>
</ul>
</details></li>
<li class="toctree-l1 has-children"><a class="reference internal" href="../hands-on/index.html">Hands-on exercises</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on0.html">Exercise 0: Hello World</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on1.html">Exercise 1: Standard Symmetric Eigenvalue Problem</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on2.html">Exercise 2: Standard Non-Symmetric Eigenvalue Problem</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on3.html">Exercise 3: Generalized Eigenvalue Problem Stored in a File</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on4.html">Exercise 4: Singular Value Decomposition</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on5.html">Exercise 5: Problem without Explicit Matrix Storage</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on6.html">Exercise 6: Parallel Execution</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on7.html">Exercise 7: Use of Deflation Subspaces</a></li>
<li class="toctree-l2"><a class="reference internal" href="../hands-on/hands-on8.html">Exercise 8: Quadratic Eigenvalue Problem</a></li>
</ul>
</details></li>
<li class="toctree-l1"><a class="reference internal" href="../faq.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../presentations.html">Presentations</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>
</div>
</nav></div>
    </div>
  
  
  <div class="sidebar-primary-items__end sidebar-primary__section">
      <div class="sidebar-primary-item">
<div id="ethical-ad-placement"
      class="flat"
      data-ea-publisher="readthedocs"
      data-ea-type="readthedocs-sidebar"
      data-ea-manual="true">
</div></div>
  </div>


      </div>
      
      <main id="main-content" class="bd-main" role="main">
        
        
          <div class="bd-content">
            <div class="bd-article-container">
              
              <div class="bd-header-article d-print-none">
<div class="header-article-items header-article__inner">
  
    <div class="header-article-items__start">
      
        <div class="header-article-item">

<nav aria-label="Breadcrumb" class="d-print-none">
  <ul class="bd-breadcrumbs">
    
    <li class="breadcrumb-item breadcrumb-home">
      <a href="../../index.html" class="nav-link" aria-label="Home">
        <i class="fa-solid fa-home"></i>
      </a>
    </li>
    
    <li class="breadcrumb-item"><a href="../index.html" class="nav-link">Documentation</a></li>
    
    
    <li class="breadcrumb-item"><a href="index.html" class="nav-link">SLEPc Users Manual</a></li>
    
    <li class="breadcrumb-item active" aria-current="page"><span class="ellipsis">Getting Started</span></li>
  </ul>
</nav>
</div>
      
    </div>
  
  
</div>
</div>
              
              
              
                
<div id="searchbox"></div>
                <article class="bd-article">
                  
  <section class="tex2jax_ignore mathjax_ignore" id="getting-started">
<span id="ch-int"></span><h1>Getting Started<a class="headerlink" href="#getting-started" title="Link to this heading">#</a></h1>
<p>SLEPc, the <em>Scalable Library for Eigenvalue Problem Computations</em>, is a software library for the solution of large sparse eigenvalue problems on parallel computers.</p>
<p>Together with systems of linear equations, eigenvalue problems are a very important class of linear algebra problems. The need for the numerical solution of these problems arises in many situations in science and engineering, in problems associated with stability and vibration analysis in practical applications. These are usually formulated as large sparse eigenproblems.</p>
<p>Computing eigenvalues is essentially more difficult than solving systems of linear equations. This has resulted in a very active research activity in the area of computational methods for eigenvalue problems in the last years, with many remarkable achievements. However, these state-of-the-art methods and algorithms are not easily transferred to the scientific community, and, apart from a few exceptions, most user still rely on simpler, well-established techniques.</p>
<p>The reasons for this situation are diverse. First, new methods are increasingly complex and difficult to implement and therefore robust implementations must be provided by computational specialists, for example as software libraries. The development of such libraries requires investing a lot of effort but sometimes they do not reach normal users due to a lack of awareness.</p>
<p>In the case of eigenproblems, using libraries is not straightforward. It is usually recommended that the user understands how the underlying algorithm works and typically the problem is successfully solved only after several cycles of testing and parameter tuning. Methods are often specific for a certain class of eigenproblems and this leads to an explosion of available algorithms from which the user has to choose. Not all these algorithms are available in the form of software libraries, even less frequently with parallel capabilities.</p>
<p>Another difficulty resides in how to represent the operator matrix. Unlike in dense methods, there is no widely accepted standard for basic sparse operations in the spirit of BLAS. This is due to the fact that sparse storage is more complicated, admitting of more variation, and therefore less standardized. For this reason, sparse libraries have an added level of complexity. This holds even more so in the case of parallel distributed-memory programming, where the data of the problem have to be distributed across the available processors.</p>
<p>The first implementations of algorithms for sparse matrices required a prescribed storage format for the sparse matrix, which is an obvious limitation. An alternative way of matrix representation is by means of a user-provided subroutine for the matrix-vector product. Apart from being format-independent, this approach allows the solution of problems in which the matrix is not available explicitly. The drawback is the restriction to a fixed-prototype subroutine.</p>
<p>A better solution for the matrix representation problem is the well-known reverse communication interface, a technique that allows the development of iterative methods disregarding the implementation details of various operations. Whenever the iterative method subroutine needs the results of one of the operations, it returns control to the user’s subroutine that called it. The user’s subroutine then invokes the module that performs the operation. The iterative method subroutine is invoked again with the results of the operation.</p>
<p>Several libraries with any of the interface schemes mentioned above are publicly available. For a survey of such software see the SLEPc Technical Report <span id="id1">[<a class="reference internal" href="#id65" title="V. Hernandez, J. E. Roman, A. Tomas, and V. Vidal. A survey of software for sparse eigenvalue problems. Technical Report STR-6, Universitat Politècnica de València, 2009. URL: https://slepc.upv.es/documentation.">Hernandez <em>et al.</em>, 2009</a>]</span> and references therein. Some of the most recent libraries are even prepared for parallel execution (some of them can be used from within SLEPc, see section <a class="reference internal" href="extra.html#sec-wrap"><span class="std std-ref">Wrappers to External Libraries</span></a>). However, they still lack some flexibility or require too much programming effort from the user, especially in the case that the eigensolution requires to employ advanced techniques such as spectral transformations or preconditioning.</p>
<p>A further obstacle appears when these libraries have to be used in the context of large software projects carried out by inter-disciplinary teams. In this scenery, libraries must be able to interoperate with already existing software and with other libraries. In order to cope with the complexity associated with such projects, libraries must be designed carefully in order to overcome hurdles such as different storage formats or programming languages. In the case of parallel software, care must be taken also to achieve portability to a wide range of platforms with good performance and still retain flexibility and usability.</p>
<section id="slepc-and-petsc">
<h2>SLEPc and PETSc<a class="headerlink" href="#slepc-and-petsc" title="Link to this heading">#</a></h2>
<p>The SLEPc library is an attempt to provide a solution to the situation described in the previous paragraphs. It is intended to be a general library for the solution of eigenvalue problems that arise in different contexts, covering standard and generalized problems, both Hermitian and non-Hermitian, with either real or complex arithmetic. Issues such as usability, portability, efficiency and interoperability are addressed, and special emphasis is put on flexibility, providing data-structure neutral implementations and multitude of run-time options. SLEPc offers a growing number of eigensolvers as well as interfaces to integrate well-established eigenvalue packages such as ARPACK. In addition to the linear eigenvalue problem, SLEPc also includes other solver classes for nonlinear eigenproblems, SVD and the computation of the action of a matrix function.</p>
<p>SLEPc is based on PETSc, the Portable, Extensible Toolkit for Scientific Computation <span id="id2">[<a class="reference internal" href="#id58" title="S. Balay, S. Abhyankar, M. F. Adams, S. Benson, J. Brown, P. Brune, K. Buschelman, E. Constantinescu, L. Dalcin, A. Dener, V. Eijkhout, J. Faibussowitsch, W. D. Gropp, V. Hapla, T. Isaac, P. Jolivet, D. Karpeev, D. Kaushik, M. G. Knepley, F. Kong, S. Kruger, D. A. May, L. Curfman McInnes, R. Tran Mills, L. Mitchell, T. Munson, J. E. Roman, K. Rupp, P. Sanan, J. Sarich, B. F. Smith, H. Suh, S. Zampini, H. Zhang, H. Zhang, and J. Zhang. PETSc/TAO Users Manual. 2025. doi:10.2172/2998643.">Balay <em>et al.</em>, 2025</a>]</span>, and, therefore, a large percentage of the software complexity is avoided since many PETSc developments are leveraged, including matrix storage formats and linear solvers, to name a few. SLEPc focuses on high level features for eigenproblems, structured around a few object classes as described below.</p>
<p>PETSc uses modern programming paradigms to ease the development of large-scale scientific application codes in Fortran, C/C++, and Python, and provides a powerful set of tools for the numerical solution of partial differential equations and related problems on high-performance computers. Its approach is to encapsulate mathematical algorithms using object-oriented programming techniques, which allow to manage the complexity of efficient numerical message-passing codes. All the PETSc software is free and used around the world in a variety of application areas.</p>
<p>The design philosophy is not to try to completely conceal parallelism from the application programmer. Rather, the user initiates a combination of sequential and parallel phases of computations, but the library handles the detailed message passing required during the coordination of computations. Some of the design principles are described in <span id="id3">[<a class="reference internal" href="#id9" title="S. Balay, W. D. Gropp, L. C. McInnes, and B. F. Smith. Efficient management of parallelism in object oriented numerical software libraries. In E. Arge, A. M. Bruaset, and H. P. Langtangen, editors, Modern Software Tools in Scientific Computing, 163–202. Birkhaüser, 1997.">Balay <em>et al.</em>, 1997</a>]</span>.</p>
<p>PETSc is built around a variety of data structures and algorithmic objects. The application programmer works directly with these objects rather than concentrating on the underlying data structures. Each component manipulates a particular family of objects (for instance, vectors) and the operations one would like to perform on the objects. The three basic abstract data objects are index sets, vectors and matrices. Built on top of this foundation are various classes of solver objects, which encapsulate virtually all information regarding the solution procedure for a particular class of problems, including the local state and various options such as convergence tolerances, etc.</p>
<p>SLEPc can be considered an extension of PETSc providing all the functionality necessary for the solution of eigenvalue problems. Figure <a class="reference internal" href="#fig-slepc"><span class="std std-ref">Numerical components of PETSc and SLEPc</span></a> shows a diagram of all the different objects included in PETSc (on the left) and those added by SLEPc (on the right). PETSc is a prerequisite for SLEPc and users should be familiar with basic concepts such as vectors and matrices in order to use SLEPc. Therefore, together with this manual we recommend to use the PETSc Users Manual <span id="id4">[<a class="reference internal" href="#id58" title="S. Balay, S. Abhyankar, M. F. Adams, S. Benson, J. Brown, P. Brune, K. Buschelman, E. Constantinescu, L. Dalcin, A. Dener, V. Eijkhout, J. Faibussowitsch, W. D. Gropp, V. Hapla, T. Isaac, P. Jolivet, D. Karpeev, D. Kaushik, M. G. Knepley, F. Kong, S. Kruger, D. A. May, L. Curfman McInnes, R. Tran Mills, L. Mitchell, T. Munson, J. E. Roman, K. Rupp, P. Sanan, J. Sarich, B. F. Smith, H. Suh, S. Zampini, H. Zhang, H. Zhang, and J. Zhang. PETSc/TAO Users Manual. 2025. doi:10.2172/2998643.">Balay <em>et al.</em>, 2025</a>]</span>.</p>
<figure class="align-default" id="fig-slepc">
<a class="reference internal image-reference" href="../../_images/fig-slepc.svg"><img alt="Numerical components of PETSc and SLEPc" src="../../_images/fig-slepc.svg" width="120%" /></a>
<figcaption>
<p><span class="caption-text">Numerical components of PETSc and SLEPc</span><a class="headerlink" href="#fig-slepc" title="Link to this image">#</a></p>
</figcaption>
</figure>
<p>Each of these components consists of an abstract interface (simply a set of calling sequences) and one or more implementations using particular data structures. Both PETSc and SLEPc are written in C, which lacks direct support for object-oriented programming. However, it is still possible to take advantage of the three basic principles of object-oriented programming to manage the complexity of such large packages. PETSc uses data <em>encapsulation</em> in both vector and matrix data objects. Application code accesses data through function calls. Also, all the operations are supported through <em>polymorphism</em>. The user calls a generic interface routine, which then selects the underlying routine that handles the particular data structure. Finally, PETSc also uses <em>inheritance</em> in its design. All the objects are derived from an abstract base object. From this fundamental object, an abstract base object is defined for each PETSc object (<a class="reference external" href="https://petsc.org/release/manualpages/Mat/Mat/" title="(in PETSc v3.24)"><span class="xref std std-doc">Mat</span></a>, <a class="reference external" href="https://petsc.org/release/manualpages/Vec/Vec/" title="(in PETSc v3.24)"><span class="xref std std-doc">Vec</span></a> and so on), which in turn has a variety of instantiations that, for example, implement different matrix storage formats.</p>
<p>PETSc/SLEPc provide clean and effective codes for the various phases of solving PDEs, with a uniform approach for each class of problems. This design enables easy comparison and use of different algorithms (for example, to experiment with different Krylov subspace methods, preconditioners, or eigensolvers). Hence, PETSc, together with SLEPc, provides a rich environment for modeling scientific applications as well as for rapid algorithm design and prototyping.</p>
<p>Options can be specified by means of calls to subroutines in the source code and also as command-line arguments. Runtime options allow the user to test different tolerances, for example, without having to recompile the program. Also, since PETSc provides a uniform interface to all of its linear solvers —the Conjugate Gradient, GMRES, etc.— and a large family of preconditioners —block Jacobi, overlapping additive Schwarz, etc.—, one can compare several combinations of method and preconditioner by simply specifying them at execution time. SLEPc shares this good property.</p>
<p>The components enable easy customization and extension of both algorithms and implementations. This approach promotes code reuse and flexibility, and separates the issues of parallelism from the choice of algorithms. The PETSc infrastructure creates a foundation for building large-scale applications.</p>
</section>
<section id="sec-inst">
<h2>Installation<a class="headerlink" href="#sec-inst" title="Link to this heading">#</a></h2>
<p>This section describes SLEPc’s installation procedure. Previously to the installation of SLEPc, the system must have an appropriate version of PETSc installed. Compatible versions of PETSc and SLEPc are those with coincident major and minor version number, the third number (patch level) being irrelevant for this. For instance, SLEPc 3.24.1 may be built with PETSc 3.24.1. Also note that, if using git repositories, both PETSc and SLEPc must be either release versions or development versions, so make sure you select the appropriate branch in both repositories (<code class="docutils notranslate"><span class="pre">git</span> <span class="pre">checkout</span> <span class="pre">release</span></code> or <code class="docutils notranslate"><span class="pre">git</span> <span class="pre">checkout</span> <span class="pre">main</span></code>).</p>
<p>The installation process for SLEPc is very similar to PETSc, with two stages: configuration and compilation. SLEPc’s configuration is much simpler because most of the configuration information is taken from PETSc, including compiler options and scalar type (real or complex). See section <a class="reference internal" href="#sec-opt-inst"><span class="std std-ref">Configuration Options</span></a> for a discussion of options that are most relevant for SLEPc. Several configurations can coexist in the same directory tree, so that for instance one can have SLEPc libraries compiled with real scalars as well as with complex scalars. This is explained in section <a class="reference internal" href="#sec-mult-inst"><span class="std std-ref">Installing Multiple Configurations in a Single Directory Tree</span></a>. Also, system-based installation is also possible with the <code class="docutils notranslate"><span class="pre">--prefix</span></code> option, as discussed in section <a class="reference internal" href="#sec-prefix-inst"><span class="std std-ref">Prefix-based Installation</span></a>.</p>
<section id="sec-std-inst">
<h3>Standard Installation<a class="headerlink" href="#sec-std-inst" title="Link to this heading">#</a></h3>
<p>The basic steps for the installation are described next. Note that prior to these steps, optional packages must have been installed. If any of these packages is installed afterwards, reconfiguration and recompilation is necessary. Refer to sections <a class="reference internal" href="#sec-opt-inst"><span class="std std-ref">Configuration Options</span></a> and <a class="reference internal" href="extra.html#sec-wrap"><span class="std std-ref">Wrappers to External Libraries</span></a> for details about installation of some of these packages.</p>
<ol class="arabic">
<li><p>Unbundle the distribution file with</p>
<pre class="literal-block">tar xzf slepc-3.24.1.tar.gz</pre>
<p>or an equivalent command. This will create a directory and unpack the software there.</p>
</li>
<li><p>Set the environment variable <code class="docutils notranslate"><span class="pre">SLEPC_DIR</span></code> to the full path of the SLEPc home directory. For example, under the <code class="docutils notranslate"><span class="pre">bash</span></code> shell:</p>
<pre class="literal-block">export SLEPC_DIR=/home/username/slepc-3.24.1</pre>
<p>In addition, the variables <code class="docutils notranslate"><span class="pre">PETSC_DIR</span></code> and <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> must also be set appropriately, e.g.</p>
<pre class="literal-block">export PETSC_DIR=/home/username/petsc-3.24.1
export PETSC_ARCH=arch-darwin-c-debug</pre>
<p>The rationale for <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> is explained in section <a class="reference internal" href="#sec-mult-inst"><span class="std std-ref">Installing Multiple Configurations in a Single Directory Tree</span></a> (see section <a class="reference internal" href="#sec-prefix-inst"><span class="std std-ref">Prefix-based Installation</span></a> for a case in which <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> is not required).</p>
</li>
</ol>
<ol class="arabic" id="step-config" start="3">
<li><p>Change to the SLEPc directory and run the configuration script:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span><span class="nv">$SLEPC_DIR</span>
<span class="gp">$ </span>./configure
</pre></div>
</div>
</li>
<li><p>If the configuration was successful, build the libraries:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>make
</pre></div>
</div>
</li>
<li><p>After the compilation, try running some test examples with</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>make<span class="w"> </span>check
</pre></div>
</div>
<p>Examine the output for any obvious errors or problems.</p>
</li>
</ol>
</section>
<section id="sec-opt-inst">
<h3>Configuration Options<a class="headerlink" href="#sec-opt-inst" title="Link to this heading">#</a></h3>
<p>Several options are available in SLEPc’s configuration script. To see all available options, type <code class="docutils notranslate"><span class="pre">./configure</span> <span class="pre">--help</span></code>.</p>
<p>In SLEPc, configure options have the following purposes:</p>
<ul>
<li><p>Specify a directory for prefix-based installation, as explained in section <a class="reference internal" href="#sec-prefix-inst"><span class="std std-ref">Prefix-based Installation</span></a>.</p></li>
<li><p>Enable compilation of Python bindings (slepc4py).</p></li>
<li><p>Enable external eigensolver packages. For example, to use ARPACK, specify the following options (with the appropriate paths):</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>./configure<span class="w"> </span>--with-arpack-dir<span class="o">=</span>/usr/software/ARPACK
</pre></div>
</div>
<p>Some of the external packages also support the <code class="docutils notranslate"><span class="pre">--download-xxxx</span></code> option. Section <a class="reference internal" href="extra.html#sec-wrap"><span class="std std-ref">Wrappers to External Libraries</span></a> provides more details related to use of external libraries.</p>
</li>
</ul>
<p>Additionally, PETSc’s configuration script provides a very long list of options that are relevant to SLEPc. Here is a list of options that may be useful. Note that these are options of PETSc that apply to both PETSc and SLEPc, in such a way that it is not possible to, e.g., build PETSc without debugging and SLEPc with debugging.</p>
<ul class="simple">
<li><p>Add <code class="docutils notranslate"><span class="pre">--with-scalar-type=complex</span></code> to build complex scalar versions of all libraries. See below a note related to complex scalars.</p></li>
<li><p>Build single precision versions with <code class="docutils notranslate"><span class="pre">--with-precision=single</span></code>. In most applications, this can achieve a significant reduction of memory requirements, and a moderate reduction of computing time. Also, quadruple precision (128-bit floating-point representation) is also available using <code class="docutils notranslate"><span class="pre">--with-precision=__float128</span></code> on systems with GNU compilers (<code class="docutils notranslate"><span class="pre">gcc-4.6</span></code> or later).</p></li>
<li><p>Enable use from Fortran. By default, PETSc’s configure looks for an appropriate Fortran compiler. If not required, this can be disabled: <code class="docutils notranslate"><span class="pre">--with-fc=0</span></code>. If required but not correctly detected, the compiler to be used can be specified with a configure option. It is also possible to configure with a Fortran compiler but do not build Fortran interfaces of PETSc and SLEPc, with <code class="docutils notranslate"><span class="pre">--with-fortran-bindings=0</span></code>.</p></li>
<li><p>If not detected, use <code class="docutils notranslate"><span class="pre">--with-blas-lapack-lib</span></code> to specify the location of BLAS and LAPACK. If SLEPc’s configure complains about some missing LAPACK subroutines, reconfigure PETSc with option <code class="docutils notranslate"><span class="pre">--download-f2cblaslapack</span></code>.</p></li>
<li><p>Enable external libraries that provide direct linear solvers or preconditioners, such as MUMPS, hypre, or SuperLU; for example, <code class="docutils notranslate"><span class="pre">--download-mumps</span></code>. These are especially relevant for SLEPc in the case that a spectral transformation is used, see chapter <a class="reference internal" href="st.html#ch-st"><span class="std std-ref">ST: Spectral Transformation</span></a>.</p></li>
<li><p>Add <code class="docutils notranslate"><span class="pre">--with-64-bit-indices=1</span></code> to use 8 byte integers (<code class="docutils notranslate"><span class="pre">long</span> <span class="pre">long</span></code>) for indexing in vectors and matrices. This is only needed when working with over roughly 2 billion unknowns.</p></li>
<li><p>Build static libraries, <code class="docutils notranslate"><span class="pre">--with-shared-libraries=0</span></code>. This is generally not recommended, since shared libraries produce smaller executables and the run time overhead is small.</p></li>
<li><p>Error-checking code can be disabled with <code class="docutils notranslate"><span class="pre">--with-debugging=0</span></code>, but this is only recommended in production runs of well-tested applications.</p></li>
<li><p>Enable GPU computing setting <code class="docutils notranslate"><span class="pre">--with-cuda=1</span></code> or <code class="docutils notranslate"><span class="pre">--with-hip=1</span></code>; see section <a class="reference internal" href="extra.html#sec-gpu"><span class="std std-ref">GPU Computing</span></a> for details.</p></li>
<li><p>The option <code class="docutils notranslate"><span class="pre">--with-mpi=0</span></code> allows building PETSc and SLEPc without MPI support (only sequential).</p></li>
</ul>
<p><strong>Note about complex scalar versions</strong>: PETSc supports the use of complex scalars by defining the data type <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscScalar/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscScalar</span></a> either as a real or complex number. This implies that two different versions of the PETSc libraries can be built separately, one for real numbers and one for complex numbers, but they cannot be used at the same time. SLEPc inherits this property. In SLEPc it is not possible to completely separate real numbers and complex numbers because the solution of non-symmetric real-valued eigenvalue problems may be complex. SLEPc has been designed trying to provide a uniform interface to manage all the possible cases. However, there are slight differences between the interface in each of the two versions. In this manual, differences are clearly identified.</p>
</section>
<section id="sec-mult-inst">
<h3>Installing Multiple Configurations in a Single Directory Tree<a class="headerlink" href="#sec-mult-inst" title="Link to this heading">#</a></h3>
<p>Often, it is necessary to build two (or more) versions of the libraries that differ in a few configuration options. For instance, versions for real and complex scalars, or versions for double and single precision, or versions with debugging and optimized. In a standard installation, this is handled by building all versions in the same directory tree, as explained below, so that source code is not replicated unnecessarily. In contrast, in prefix-based installation where source code is not present, the issue of multiple configurations is handled differently, as explained in section <a class="reference internal" href="#sec-prefix-inst"><span class="std std-ref">Prefix-based Installation</span></a>.</p>
<p>In a standard installation, the different configurations are identified by a unique name that is assigned to the environment variable <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code>. Let us illustrate how to set up PETSc with two configurations. First, set a value of <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> and proceed with the installation of the first one:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span><span class="nv">$PETSC_DIR</span>
<span class="gp">$ </span><span class="nb">export</span><span class="w"> </span><span class="nv">PETSC_ARCH</span><span class="o">=</span>arch-linux-gnu-c-debug-real
<span class="gp">$ </span>./configure<span class="w"> </span>--with-scalar-type<span class="o">=</span>real
<span class="gp">$ </span>make<span class="w"> </span>all
</pre></div>
</div>
<p>Note that if <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> is not given a value, PETSc suggests one for us. After this, a subdirectory named <code class="docutils notranslate"><span class="pre">$PETSC_ARCH</span></code> is created within <code class="docutils notranslate"><span class="pre">$PETSC_DIR</span></code>, that stores all information associated with that configuration, including the built libraries, configuration files, automatically generated source files, and log files. For the second configuration, proceed similarly:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span><span class="nb">cd</span><span class="w"> </span><span class="nv">$PETSC_DIR</span>
<span class="gp">$ </span><span class="nb">export</span><span class="w"> </span><span class="nv">PETSC_ARCH</span><span class="o">=</span>arch-linux-gnu-c-debug-complex
<span class="gp">$ </span>./configure<span class="w"> </span>--with-scalar-type<span class="o">=</span>complex
<span class="gp">$ </span>make<span class="w"> </span>all
</pre></div>
</div>
<p>The value of <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> in this case must be different than the previous one. It is better to set the value of <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> explicitly, because the name suggested by <code class="docutils notranslate"><span class="pre">configure</span></code> may coincide with an existing value, thus overwriting a previous configuration. After successful installation of the second configuration, two <code class="docutils notranslate"><span class="pre">$PETSC_ARCH</span></code> directories exist within <code class="docutils notranslate"><span class="pre">$PETSC_DIR</span></code>, and the user can easily choose to build his/her application with either configuration by simply changing the value of <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code>.</p>
<p>The configuration of two versions of SLEPc in the same directory tree is very similar. The only important restriction is that the value of <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> used in SLEPc must exactly match an existing PETSc configuration, that is, a directory <code class="docutils notranslate"><span class="pre">$PETSC_DIR/$PETSC_ARCH</span></code> must exist.</p>
</section>
<section id="sec-prefix-inst">
<h3>Prefix-based Installation<a class="headerlink" href="#sec-prefix-inst" title="Link to this heading">#</a></h3>
<p>Both PETSc and SLEPc allow for prefix-based installation. This consists in specifying a directory to which the files generated during the building process are to be copied.</p>
<p>In PETSc, if an installation directory has been specified during configuration (with option <code class="docutils notranslate"><span class="pre">--prefix</span></code> in step <a class="reference internal" href="#step-config">configuration</a> of section <a class="reference internal" href="#sec-std-inst"><span class="std std-ref">Standard Installation</span></a>), then after building the libraries the relevant files are copied to that directory by typing</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>make<span class="w"> </span>install
</pre></div>
</div>
<p>This is useful for building as a regular user and then copying the libraries and include files to the system directories as root.</p>
<p>To be more precise, suppose that the configuration was done with <code class="docutils notranslate"><span class="pre">--prefix=/opt/petsc-x.x-linux-gnu-c-debug</span></code>. Then, <code class="docutils notranslate"><span class="pre">make</span> <span class="pre">install</span></code> will create directory <code class="docutils notranslate"><span class="pre">/opt/petsc-x.x-linux-gnu-c-debug</span></code> if it does not exist, and several subdirectories containing the libraries, the configuration files, and the header files. Note that the source code files are not copied, nor the documentation, so the size of the installed directory will be much smaller than the original one. For that reason, it is no longer necessary to allow for several configurations to share a directory tree. In other words, in a prefix-based installation, variable <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> loses significance and must be unset. To maintain several configurations, one should specify different prefix directories, typically with a name that informs about the configuration options used.</p>
<p>In order to prepare a prefix-based installation of SLEPc that uses a prefix-based installation of PETSc, start by setting the appropriate value of <code class="docutils notranslate"><span class="pre">PETSC_DIR</span></code>. Then, run SLEPc’s configure with a prefix directory.</p>
<pre class="literal-block">export PETSC_DIR=/opt/petsc-3.24.1-linux-gnu-c-debug
unset PETSC_ARCH
cd $SLEPC_DIR
./configure --prefix=/opt/slepc-3.24.1-linux-gnu-c-debug
make
make install
export SLEPC_DIR=/opt/slepc-3.24.1-linux-gnu-c-debug</pre>
<p>Note that the variable <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> has been unset before SLEPc’s configure. SLEPc will use a temporary arch name during the build (this temporary arch is named <code class="docutils notranslate"><span class="pre">installed-arch-xxx</span></code>, where the <code class="docutils notranslate"><span class="pre">arch-xxx</span></code> string represents the configuration of the installed PETSc version). Although it is not a common case, it is also possible to configure SLEPc without prefix, in which case the <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> variable must still be empty and the arch directory <code class="docutils notranslate"><span class="pre">installed-xxx</span></code> is picked automatically (it is hardwired in file <code class="docutils notranslate"><span class="pre">$SLEPC_DIR/lib/slepc/conf/slepcvariables</span></code>). The combination PETSc without prefix and SLEPc with prefix is also allowed, in which case <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> should not be unset.</p>
</section>
</section>
<section id="running-slepc-programs">
<h2>Running SLEPc Programs<a class="headerlink" href="#running-slepc-programs" title="Link to this heading">#</a></h2>
<p>Before using SLEPc, the user must first set the environment variable <code class="docutils notranslate"><span class="pre">SLEPC_DIR</span></code>, indicating the full path of the directory containing SLEPc. For example, under the <code class="docutils notranslate"><span class="pre">bash</span></code> shell, a command of the form</p>
<pre class="literal-block">export SLEPC_DIR=/software/slepc-3.24.1</pre>
<p>can be placed in the user’s <code class="docutils notranslate"><span class="pre">.bashrc</span></code> file. The <code class="docutils notranslate"><span class="pre">SLEPC_DIR</span></code> directory can be either a standard installation SLEPc directory, or a prefix-based installation directory, see section <a class="reference internal" href="#sec-prefix-inst"><span class="std std-ref">Prefix-based Installation</span></a>. In addition, the user must set the environment variables required by PETSc, that is, <code class="docutils notranslate"><span class="pre">PETSC_DIR</span></code>, to indicate the full path of the PETSc directory, and <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> to specify a particular architecture and set of options. Note that <code class="docutils notranslate"><span class="pre">PETSC_ARCH</span></code> should not be set in the case of prefix-based installations.</p>
<p>All PETSc programs use the MPI (Message Passing Interface) standard for message-passing communication <span id="id5">[<a class="reference internal" href="#id60" title="MPI Forum. MPI: a message-passing interface standard. Int. J. Supercomp. Applic. High Perf. Comp., 8(3/4):159–416, 1994.">MPI Forum, 1994</a>]</span>. Thus, to execute SLEPc programs, users must know the procedure for launching MPI jobs on their selected computer system(s). Usually, the <code class="docutils notranslate"><span class="pre">mpiexec</span></code> command can be used to initiate a program as in the following example that uses eight processes:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>mpiexec<span class="w"> </span>-n<span class="w"> </span><span class="m">8</span><span class="w"> </span>slepc_program<span class="w"> </span><span class="o">[</span>command-line<span class="w"> </span>options<span class="o">]</span>
</pre></div>
</div>
<p>Note that MPI may be deactivated during configuration of PETSc, if one wants to run only serial programs in a laptop, for example.</p>
<p>All PETSc-compliant programs support the use of the <code class="docutils notranslate"><span class="pre">-h</span></code> or <code class="docutils notranslate"><span class="pre">-help</span></code> option as well as the <code class="docutils notranslate"><span class="pre">-v</span></code> or <code class="docutils notranslate"><span class="pre">-version</span></code> option. In the case of SLEPc programs, specific information for SLEPc is also displayed.</p>
</section>
<section id="sec-writing-prog">
<h2>Writing SLEPc Programs<a class="headerlink" href="#sec-writing-prog" title="Link to this heading">#</a></h2>
<p>Most SLEPc programs begin with a call to <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/Sys/SlepcInitialize.html">SlepcInitialize</a>()</span></code></p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n"><a href="../../manualpages/Sys/SlepcInitialize.html">SlepcInitialize</a></span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="o">*</span><span class="n">argc</span><span class="p">,</span><span class="kt">char</span><span class="w"> </span><span class="o">***</span><span class="n">args</span><span class="p">,</span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">file</span><span class="p">[],</span><span class="k">const</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">help</span><span class="p">[]);</span>
</pre></div>
</div>
<p>which initializes SLEPc, PETSc and MPI. This subroutine is very similar to <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscInitialize/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscInitialize</span></a>(), and the arguments have the same meaning. In fact, internally <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/Sys/SlepcInitialize.html">SlepcInitialize</a>()</span></code> calls <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscInitialize/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscInitialize</span></a>().</p>
<p>After this initialization, SLEPc programs can use communicators defined by PETSc. In most cases users can employ the communicator <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/" title="(in PETSc v3.24)"><span class="xref std std-doc">PETSC_COMM_WORLD</span></a> to indicate all processes in a given run and <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_SELF/" title="(in PETSc v3.24)"><span class="xref std std-doc">PETSC_COMM_SELF</span></a> to indicate a single process. MPI provides routines for generating new communicators consisting of subsets of processes, though most users rarely need to use these features. SLEPc users need not program much message passing directly with MPI, but they must be familiar with the basic concepts of message passing and distributed memory computing.</p>
<p>All SLEPc programs should call <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/Sys/SlepcFinalize.html">SlepcFinalize</a>()</span></code> as their final (or nearly final) statement</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n"><a href="../../manualpages/Sys/SlepcFinalize.html">SlepcFinalize</a></span><span class="p">();</span>
</pre></div>
</div>
<p>This routine handles operations to be executed at the conclusion of the program, and calls <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscFinalize/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscFinalize</span></a>() if <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/Sys/SlepcInitialize.html">SlepcInitialize</a>()</span></code> began PETSc.</p>
<p><strong>Note to Fortran Programmers</strong>: In this manual all the examples and calling sequences are given for the C/C++ programming languages. However, Fortran programmers can use most of the functionality of SLEPc and PETSc from Fortran, with only minor differences in the user interface. For instance, the two functions mentioned above have their corresponding Fortran equivalent:</p>
<div class="highlight-Fortran notranslate"><div class="highlight"><pre><span></span><span class="k">call </span><span class="n"><a href="../../manualpages/Sys/SlepcInitialize.html">SlepcInitialize</a></span><span class="p">(</span><span class="k">file</span><span class="p">,</span><span class="n">ierr</span><span class="p">)</span>
<span class="k">call </span><span class="n"><a href="../../manualpages/Sys/SlepcFinalize.html">SlepcFinalize</a></span><span class="p">(</span><span class="n">ierr</span><span class="p">)</span>
</pre></div>
</div>
<p>Section <a class="reference internal" href="extra.html#sec-fortran"><span class="std std-ref">Fortran Interface</span></a> provides a summary of the differences between using SLEPc from Fortran and C/C++, as well as a complete Fortran example.</p>
<section id="sec-simpleex">
<h3>Simple SLEPc Example<a class="headerlink" href="#sec-simpleex" title="Link to this heading">#</a></h3>
<p>A simple example is listed next that solves an eigenvalue problem associated with the one-dimensional Laplacian operator discretized with finite differences. This example can be found in <code class="docutils notranslate"><span class="pre">${SLEPC_DIR}/src/eps/tutorials/ex1.c</span></code>. Following the code we highlight a few of the most important parts of this example.</p>
<div class="highlight-c notranslate" id="ex1-c"><div class="highlight"><pre><span></span>
<span class="k">static</span><span class="w"> </span><span class="kt">char</span><span class="w"> </span><span class="n">help</span><span class="p">[]</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&quot;Standard symmetric eigenproblem corresponding to the Laplacian operator in 1 dimension.</span><span class="se">\n\n</span><span class="s">&quot;</span>
<span class="w">  </span><span class="s">&quot;The command line options are:</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="w">  </span><span class="s">&quot;  -n &lt;n&gt;, where &lt;n&gt; = number of grid subdivisions = matrix dimension.</span><span class="se">\n\n</span><span class="s">&quot;</span><span class="p">;</span>

<span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;slepceps.h&gt;</span>

<span class="kt">int</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">argc</span><span class="p">,</span><span class="kt">char</span><span class="w"> </span><span class="o">**</span><span class="n">argv</span><span class="p">)</span>
<span class="p">{</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/Mat/">Mat</a></span><span class="w">            </span><span class="n">A</span><span class="p">;</span><span class="w">           </span><span class="cm">/* problem matrix */</span>
<span class="w">  </span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w">            </span><span class="n">eps</span><span class="p">;</span><span class="w">         </span><span class="cm">/* eigenproblem solver context */</span>
<span class="w">  </span><span class="n"><a href="../../manualpages/EPS/EPSType.html">EPSType</a></span><span class="w">        </span><span class="n">type</span><span class="p">;</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscReal/">PetscReal</a></span><span class="w">      </span><span class="n">error</span><span class="p">,</span><span class="n">tol</span><span class="p">,</span><span class="n">re</span><span class="p">,</span><span class="n">im</span><span class="p">;</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscScalar/">PetscScalar</a></span><span class="w">    </span><span class="n">kr</span><span class="p">,</span><span class="n">ki</span><span class="p">;</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Vec/Vec/">Vec</a></span><span class="w">            </span><span class="n">xr</span><span class="p">,</span><span class="n">xi</span><span class="p">;</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w">       </span><span class="n">n</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">Istart</span><span class="p">,</span><span class="n">Iend</span><span class="p">,</span><span class="n">nev</span><span class="p">,</span><span class="n">maxit</span><span class="p">,</span><span class="n">its</span><span class="p">,</span><span class="n">nconv</span><span class="p">;</span>

<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscFunctionBeginUser/">PetscFunctionBeginUser</a></span><span class="p">;</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/Sys/SlepcInitialize.html">SlepcInitialize</a></span><span class="p">(</span><span class="o">&amp;</span><span class="n">argc</span><span class="p">,</span><span class="o">&amp;</span><span class="n">argv</span><span class="p">,</span><span class="nb">NULL</span><span class="p">,</span><span class="n">help</span><span class="p">));</span>

<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscOptionsGetInt/">PetscOptionsGetInt</a></span><span class="p">(</span><span class="nb">NULL</span><span class="p">,</span><span class="nb">NULL</span><span class="p">,</span><span class="s">&quot;-n&quot;</span><span class="p">,</span><span class="o">&amp;</span><span class="n">n</span><span class="p">,</span><span class="nb">NULL</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot;</span><span class="se">\n</span><span class="s">1-D Laplacian Eigenproblem, n=%&quot;</span><span class="w"> </span><span class="n">PetscInt_FMT</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n\n</span><span class="s">&quot;</span><span class="p">,</span><span class="n">n</span><span class="p">));</span>

<span class="w">  </span><span class="cm">/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
<span class="cm">     Compute the operator matrix that defines the eigensystem, Ax=kx</span>
<span class="cm">     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */</span>

<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatCreate/">MatCreate</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="o">&amp;</span><span class="n">A</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetSizes/">MatSetSizes</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_DECIDE/">PETSC_DECIDE</a></span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_DECIDE/">PETSC_DECIDE</a></span><span class="p">,</span><span class="n">n</span><span class="p">,</span><span class="n">n</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetFromOptions/">MatSetFromOptions</a></span><span class="p">(</span><span class="n">A</span><span class="p">));</span>

<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatGetOwnershipRange/">MatGetOwnershipRange</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="o">&amp;</span><span class="n">Istart</span><span class="p">,</span><span class="o">&amp;</span><span class="n">Iend</span><span class="p">));</span>
<span class="w">  </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="o">=</span><span class="n">Istart</span><span class="p">;</span><span class="n">i</span><span class="o">&lt;</span><span class="n">Iend</span><span class="p">;</span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetValue/">MatSetValue</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">i</span><span class="mi">-1</span><span class="p">,</span><span class="mf">-1.0</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/INSERT_VALUES/">INSERT_VALUES</a></span><span class="p">));</span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="o">&lt;</span><span class="n">n</span><span class="mi">-1</span><span class="p">)</span><span class="w"> </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetValue/">MatSetValue</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span><span class="mf">-1.0</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/INSERT_VALUES/">INSERT_VALUES</a></span><span class="p">));</span>
<span class="w">    </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetValue/">MatSetValue</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="mf">2.0</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/INSERT_VALUES/">INSERT_VALUES</a></span><span class="p">));</span>
<span class="w">  </span><span class="p">}</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatAssemblyBegin/">MatAssemblyBegin</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">MAT_FINAL_ASSEMBLY</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatAssemblyEnd/">MatAssemblyEnd</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="n">MAT_FINAL_ASSEMBLY</span><span class="p">));</span>

<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatCreateVecs/">MatCreateVecs</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="nb">NULL</span><span class="p">,</span><span class="o">&amp;</span><span class="n">xr</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatCreateVecs/">MatCreateVecs</a></span><span class="p">(</span><span class="n">A</span><span class="p">,</span><span class="nb">NULL</span><span class="p">,</span><span class="o">&amp;</span><span class="n">xi</span><span class="p">));</span>

<span class="w">  </span><span class="cm">/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
<span class="cm">                Create the eigensolver and set various options</span>
<span class="cm">     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */</span>
<span class="w">  </span><span class="cm">/*</span>
<span class="cm">     Create eigensolver context</span>
<span class="cm">  */</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSCreate.html">EPSCreate</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="o">&amp;</span><span class="n">eps</span><span class="p">));</span>

<span class="w">  </span><span class="cm">/*</span>
<span class="cm">     Set operators. In this case, it is a standard eigenvalue problem</span>
<span class="cm">  */</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSSetOperators.html">EPSSetOperators</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="n">A</span><span class="p">,</span><span class="nb">NULL</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSSetProblemType.html">EPSSetProblemType</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="n"><a href="../../manualpages/EPS/EPS_HEP.html">EPS_HEP</a></span><span class="p">));</span>

<span class="w">  </span><span class="cm">/*</span>
<span class="cm">     Set solver parameters at runtime</span>
<span class="cm">  */</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSSetFromOptions.html">EPSSetFromOptions</a></span><span class="p">(</span><span class="n">eps</span><span class="p">));</span>

<span class="w">  </span><span class="cm">/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
<span class="cm">                      Solve the eigensystem</span>
<span class="cm">     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */</span>

<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSSolve.html">EPSSolve</a></span><span class="p">(</span><span class="n">eps</span><span class="p">));</span>
<span class="w">  </span><span class="cm">/*</span>
<span class="cm">     Optional: Get some information from the solver and display it</span>
<span class="cm">  */</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSGetIterationNumber.html">EPSGetIterationNumber</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="o">&amp;</span><span class="n">its</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot; Number of iterations of the method: %&quot;</span><span class="w"> </span><span class="n">PetscInt_FMT</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span><span class="n">its</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSGetType.html">EPSGetType</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="o">&amp;</span><span class="n">type</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot; Solution method: %s</span><span class="se">\n\n</span><span class="s">&quot;</span><span class="p">,</span><span class="n">type</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSGetDimensions.html">EPSGetDimensions</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="o">&amp;</span><span class="n">nev</span><span class="p">,</span><span class="nb">NULL</span><span class="p">,</span><span class="nb">NULL</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot; Number of requested eigenvalues: %&quot;</span><span class="w"> </span><span class="n">PetscInt_FMT</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span><span class="n">nev</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSGetTolerances.html">EPSGetTolerances</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="o">&amp;</span><span class="n">tol</span><span class="p">,</span><span class="o">&amp;</span><span class="n">maxit</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot; Stopping condition: tol=%.4g, maxit=%&quot;</span><span class="w"> </span><span class="n">PetscInt_FMT</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,(</span><span class="kt">double</span><span class="p">)</span><span class="n">tol</span><span class="p">,</span><span class="n">maxit</span><span class="p">));</span>

<span class="w">  </span><span class="cm">/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -</span>
<span class="cm">                    Display solution and clean up</span>
<span class="cm">     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */</span>
<span class="w">  </span><span class="cm">/*</span>
<span class="cm">     Get number of converged approximate eigenpairs</span>
<span class="cm">  */</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSGetConverged.html">EPSGetConverged</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="o">&amp;</span><span class="n">nconv</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot; Number of converged eigenpairs: %&quot;</span><span class="w"> </span><span class="n">PetscInt_FMT</span><span class="w"> </span><span class="s">&quot;</span><span class="se">\n\n</span><span class="s">&quot;</span><span class="p">,</span><span class="n">nconv</span><span class="p">));</span>

<span class="w">  </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">nconv</span><span class="o">&gt;</span><span class="mi">0</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">    </span><span class="cm">/*</span>
<span class="cm">       Display eigenvalues and relative errors</span>
<span class="cm">    */</span>
<span class="w">    </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span>
<span class="w">         </span><span class="s">&quot;           k          ||Ax-kx||/||kx||</span><span class="se">\n</span><span class="s">&quot;</span>
<span class="w">         </span><span class="s">&quot;   ----------------- ------------------</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">));</span>

<span class="w">    </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="n">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span><span class="n">i</span><span class="o">&lt;</span><span class="n">nconv</span><span class="p">;</span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w">      </span><span class="cm">/*</span>
<span class="cm">        Get converged eigenpairs: i-th eigenvalue is stored in kr (real part) and</span>
<span class="cm">        ki (imaginary part)</span>
<span class="cm">      */</span>
<span class="w">      </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSGetEigenpair.html">EPSGetEigenpair</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="o">&amp;</span><span class="n">kr</span><span class="p">,</span><span class="o">&amp;</span><span class="n">ki</span><span class="p">,</span><span class="n">xr</span><span class="p">,</span><span class="n">xi</span><span class="p">));</span>
<span class="w">      </span><span class="cm">/*</span>
<span class="cm">         Compute the relative error associated to each eigenpair</span>
<span class="cm">      */</span>
<span class="w">      </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSComputeError.html">EPSComputeError</a></span><span class="p">(</span><span class="n">eps</span><span class="p">,</span><span class="n">i</span><span class="p">,</span><span class="n"><a href="../../manualpages/EPS/EPSErrorType.html">EPS_ERROR_RELATIVE</a></span><span class="p">,</span><span class="o">&amp;</span><span class="n">error</span><span class="p">));</span>

<span class="cp">#if defined(PETSC_USE_COMPLEX)</span>
<span class="w">      </span><span class="n">re</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscRealPart/">PetscRealPart</a></span><span class="p">(</span><span class="n">kr</span><span class="p">);</span>
<span class="w">      </span><span class="n">im</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscImaginaryPart/">PetscImaginaryPart</a></span><span class="p">(</span><span class="n">kr</span><span class="p">);</span>
<span class="cp">#else</span>
<span class="w">      </span><span class="n">re</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">kr</span><span class="p">;</span>
<span class="w">      </span><span class="n">im</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ki</span><span class="p">;</span>
<span class="cp">#endif</span>
<span class="w">      </span><span class="k">if</span><span class="w"> </span><span class="p">(</span><span class="n">im</span><span class="o">!=</span><span class="mf">0.0</span><span class="p">)</span><span class="w"> </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot; %9f%+9fi %12g</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,(</span><span class="kt">double</span><span class="p">)</span><span class="n">re</span><span class="p">,(</span><span class="kt">double</span><span class="p">)</span><span class="n">im</span><span class="p">,(</span><span class="kt">double</span><span class="p">)</span><span class="n">error</span><span class="p">));</span>
<span class="w">      </span><span class="k">else</span><span class="w"> </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot;   %12f       %12g</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,(</span><span class="kt">double</span><span class="p">)</span><span class="n">re</span><span class="p">,(</span><span class="kt">double</span><span class="p">)</span><span class="n">error</span><span class="p">));</span>
<span class="w">    </span><span class="p">}</span>
<span class="w">    </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscPrintf/">PetscPrintf</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PETSC_COMM_WORLD/">PETSC_COMM_WORLD</a></span><span class="p">,</span><span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">));</span>
<span class="w">  </span><span class="p">}</span>

<span class="w">  </span><span class="cm">/*</span>
<span class="cm">     Free work space</span>
<span class="cm">  */</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPSDestroy.html">EPSDestroy</a></span><span class="p">(</span><span class="o">&amp;</span><span class="n">eps</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatDestroy/">MatDestroy</a></span><span class="p">(</span><span class="o">&amp;</span><span class="n">A</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Vec/VecDestroy/">VecDestroy</a></span><span class="p">(</span><span class="o">&amp;</span><span class="n">xr</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Vec/VecDestroy/">VecDestroy</a></span><span class="p">(</span><span class="o">&amp;</span><span class="n">xi</span><span class="p">));</span>
<span class="w">  </span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscCall/">PetscCall</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/Sys/SlepcFinalize.html">SlepcFinalize</a></span><span class="p">());</span>
<span class="w">  </span><span class="k">return</span><span class="w"> </span><span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p><strong>Include Files</strong>. The C/C++ include files for SLEPc should be used via statements such as</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#include</span><span class="w"> </span><span class="cpf">&lt;slepceps.h&gt;</span>
</pre></div>
</div>
<p>where <code class="docutils notranslate"><span class="pre">slepceps.h</span></code> is the include file for the <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/EPS/EPS.html">EPS</a></span></code> component. Each SLEPc program must specify an include file that corresponds to the highest level SLEPc objects needed within the program; all of the required lower level include files are automatically included within the higher level files. For example, <code class="docutils notranslate"><span class="pre">slepceps.h</span></code> includes <code class="docutils notranslate"><span class="pre">slepcst.h</span></code> (spectral transformations), and <code class="docutils notranslate"><span class="pre">slepcsys.h</span></code> (base SLEPc file). Some PETSc header files are included as well, such as <code class="docutils notranslate"><span class="pre">petscksp.h</span></code>. The SLEPc include files are located in the directory <code class="docutils notranslate"><span class="pre">${SLEPC_DIR}/include</span></code>.</p>
<p><strong>The Options Database</strong>. All the PETSc functionality related to the options database is available in SLEPc. This allows the user to input control data at run time very easily. In this example, the call <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscOptionsGetInt/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscOptionsGetInt</span></a><code class="docutils notranslate"><span class="pre">(NULL,NULL,&quot;-n&quot;,&amp;n,NULL)</span></code> checks whether the user has provided a command line option to set the value of <code class="docutils notranslate"><span class="pre">n</span></code>, the problem dimension. If so, the variable <code class="docutils notranslate"><span class="pre">n</span></code> is set accordingly; otherwise, <code class="docutils notranslate"><span class="pre">n</span></code> remains unchanged.</p>
<p><strong>Vectors and Matrices</strong>. Usage of matrices and vectors in SLEPc is exactly the same as in PETSc. The user can create a new parallel or sequential matrix, <code class="docutils notranslate"><span class="pre">A</span></code>, which has <code class="docutils notranslate"><span class="pre">M</span></code> global rows and <code class="docutils notranslate"><span class="pre">N</span></code> global columns, with</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatCreate/">MatCreate</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/MPI_Comm/">MPI_Comm</a></span><span class="w"> </span><span class="n">comm</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/Mat/">Mat</a></span><span class="w"> </span><span class="o">*</span><span class="n">A</span><span class="p">);</span>
<span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetSizes/">MatSetSizes</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/Mat/">Mat</a></span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w"> </span><span class="n">m</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w"> </span><span class="n">n</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w"> </span><span class="n">M</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w"> </span><span class="n">N</span><span class="p">);</span>
<span class="n"><a href="https://petsc.org/release/manualpages/Mat/MatSetFromOptions/">MatSetFromOptions</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/Mat/">Mat</a></span><span class="w"> </span><span class="n">A</span><span class="p">);</span>
</pre></div>
</div>
<p>where the matrix format can be specified at runtime. The example creates a matrix, sets the nonzero values with <a class="reference external" href="https://petsc.org/release/manualpages/Mat/MatSetValues/" title="(in PETSc v3.24)"><span class="xref std std-doc">MatSetValues</span></a>() and then assembles it.</p>
<p><strong>Eigensolvers</strong>. Usage of eigensolvers is very similar to other kinds of solvers provided by PETSc. After creating the matrix (or matrices) that define the problem, <span class="math notranslate nohighlight">\(Ax = kx\)</span> (or <span class="math notranslate nohighlight">\(Ax=kBx\)</span>), the user can then use <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/EPS/EPS.html">EPS</a></span></code> to solve the system with the following sequence of commands:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n"><a href="../../manualpages/EPS/EPSCreate.html">EPSCreate</a></span><span class="p">(</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/MPI_Comm/">MPI_Comm</a></span><span class="w"> </span><span class="n">comm</span><span class="p">,</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="o">*</span><span class="n">eps</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSSetOperators.html">EPSSetOperators</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="n">eps</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/Mat/">Mat</a></span><span class="w"> </span><span class="n">A</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Mat/Mat/">Mat</a></span><span class="w"> </span><span class="n">B</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSSetProblemType.html">EPSSetProblemType</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="n">eps</span><span class="p">,</span><span class="n"><a href="../../manualpages/EPS/EPSProblemType.html">EPSProblemType</a></span><span class="w"> </span><span class="n">type</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSSetFromOptions.html">EPSSetFromOptions</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="n">eps</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSSolve.html">EPSSolve</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="n">eps</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSGetConverged.html">EPSGetConverged</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="n">eps</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w"> </span><span class="o">*</span><span class="n">nconv</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSGetEigenpair.html">EPSGetEigenpair</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="n">eps</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscInt/">PetscInt</a></span><span class="w"> </span><span class="n">i</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscScalar/">PetscScalar</a></span><span class="w"> </span><span class="o">*</span><span class="n">kr</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Sys/PetscScalar/">PetscScalar</a></span><span class="w"> </span><span class="o">*</span><span class="n">ki</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Vec/Vec/">Vec</a></span><span class="w"> </span><span class="n">xr</span><span class="p">,</span><span class="n"><a href="https://petsc.org/release/manualpages/Vec/Vec/">Vec</a></span><span class="w"> </span><span class="n">xi</span><span class="p">);</span>
<span class="n"><a href="../../manualpages/EPS/EPSDestroy.html">EPSDestroy</a></span><span class="p">(</span><span class="n"><a href="../../manualpages/EPS/EPS.html">EPS</a></span><span class="w"> </span><span class="o">*</span><span class="n">eps</span><span class="p">);</span>
</pre></div>
</div>
<p>The user first creates the <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/EPS/EPS.html">EPS</a></span></code> context and sets the operators associated with the eigensystem as well as the problem type. The user then sets various options for customized solution, solves the problem, retrieves the solution, and finally destroys the <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/EPS/EPS.html">EPS</a></span></code> context. Chapter <a class="reference internal" href="eps.html#ch-eps"><span class="std std-ref">EPS: Eigenvalue Problem Solver</span></a> describes in detail the <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/EPS/EPS.html">EPS</a></span></code> package, including the options database that enables the user to customize the solution process at runtime by selecting the solution algorithm and also specifying the convergence tolerance, the number of eigenvalues, the dimension of the subspace, etc.</p>
<p><strong>Spectral Transformation</strong>. In the example program shown above there is no explicit reference to spectral transformations. However, an <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/ST/ST.html">ST</a></span></code> object is handled internally so that the user is able to request different transformations such as shift-and-invert. Chapter <a class="reference internal" href="st.html#ch-st"><span class="std std-ref">ST: Spectral Transformation</span></a> describes the <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/ST/ST.html">ST</a></span></code> package in detail.</p>
<p><strong>Error Checking</strong>. All SLEPc routines return an integer indicating whether an error has occurred during the call. The error code is set to be nonzero if an error has been detected; otherwise, it is zero. The PETSc macro <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscCall/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscCall</span></a><code class="docutils notranslate"><span class="pre">(...)</span></code> checks the return value and calls the PETSc error handler upon error detection. <a class="reference external" href="https://petsc.org/release/manualpages/Sys/PetscCall/" title="(in PETSc v3.24)"><span class="xref std std-doc">PetscCall</span></a><code class="docutils notranslate"><span class="pre">(...)</span></code> should be used in all subroutine calls to enable a complete error traceback. See the PETSc documentation for full details.</p>
</section>
<section id="writing-application-codes-with-slepc">
<h3>Writing Application Codes with SLEPc<a class="headerlink" href="#writing-application-codes-with-slepc" title="Link to this heading">#</a></h3>
<p>Several example programs demonstrate the software usage and can serve as templates for developing custom applications. They are scattered throughout the SLEPc directory tree, in particular in the <code class="docutils notranslate"><span class="pre">tutorials</span></code> directories under each class subdirectory.</p>
<p>To write a new application program using SLEPc, we suggest the following procedure:</p>
<ol class="arabic simple">
<li><p>Install and test SLEPc according to the instructions given in <a class="reference internal" href="#sec-inst"><span class="std std-ref">Installation</span></a>.</p></li>
<li><p>Copy the SLEPc example that corresponds to the class of problem of interest (e.g., singular value decomposition).</p></li>
<li><p>Create a makefile as explained below, compile and run the example program.</p></li>
<li><p>Use the example program as a starting point for developing a custom code.</p></li>
</ol>
<p>Application program makefiles can be set up very easily just by including one file from the SLEPc makefile system. All the necessary PETSc definitions are loaded automatically. The following sample makefile illustrates how to build C and Fortran programs:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">default</span><span class="o">:</span><span class="w"> </span><span class="n">ex1</span>

<span class="n">include</span><span class="w"> </span><span class="n">$</span><span class="p">{</span><span class="n">SLEPC_DIR</span><span class="p">}</span><span class="o">/</span><span class="n">lib</span><span class="o">/</span><span class="n">slepc</span><span class="o">/</span><span class="n">conf</span><span class="o">/</span><span class="n">slepc_common</span>

<span class="nl">ex1</span><span class="p">:</span><span class="w"> </span><span class="n">ex1</span><span class="p">.</span><span class="n">o</span>
<span class="w">        </span><span class="o">-</span><span class="n">$</span><span class="p">{</span><span class="n">CLINKER</span><span class="p">}</span><span class="w"> </span><span class="o">-</span><span class="n">o</span><span class="w"> </span><span class="n">ex1</span><span class="w"> </span><span class="n">ex1</span><span class="p">.</span><span class="n">o</span><span class="w"> </span><span class="n">$</span><span class="p">{</span><span class="n">SLEPC_EPS_LIB</span><span class="p">}</span>
<span class="w">        </span><span class="n">$</span><span class="p">{</span><span class="n">RM</span><span class="p">}</span><span class="w"> </span><span class="n">ex1</span><span class="p">.</span><span class="n">o</span>

<span class="nl">ex1f</span><span class="p">:</span><span class="w"> </span><span class="n">ex1f</span><span class="p">.</span><span class="n">o</span>
<span class="w">        </span><span class="o">-</span><span class="n">$</span><span class="p">{</span><span class="n">FLINKER</span><span class="p">}</span><span class="w"> </span><span class="o">-</span><span class="n">o</span><span class="w"> </span><span class="n">ex1f</span><span class="w"> </span><span class="n">ex1f</span><span class="p">.</span><span class="n">o</span><span class="w"> </span><span class="n">$</span><span class="p">{</span><span class="n">SLEPC_EPS_LIB</span><span class="p">}</span>
<span class="w">        </span><span class="n">$</span><span class="p">{</span><span class="n">RM</span><span class="p">}</span><span class="w"> </span><span class="n">ex1f</span><span class="p">.</span><span class="n">o</span>
</pre></div>
</div>
<p>Replace <code class="docutils notranslate"><span class="pre"><a href="../../manualpages/EPS/EPS.html">EPS</a></span></code> in <code class="docutils notranslate"><span class="pre">${SLEPC_EPS_LIB}</span></code> with the highest level module you are using in your program.</p>
<p class="rubric">References</p>
<div class="docutils container" id="id6">
<div role="list" class="citation-list">
<div class="citation" id="id58" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span>BalPU<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#id2">1</a>,<a role="doc-backlink" href="#id4">2</a>)</span>
<p>S. Balay, S. Abhyankar, M. F. Adams, S. Benson, J. Brown, P. Brune, K. Buschelman, E. Constantinescu, L. Dalcin, A. Dener, V. Eijkhout, J. Faibussowitsch, W. D. Gropp, V. Hapla, T. Isaac, P. Jolivet, D. Karpeev, D. Kaushik, M. G. Knepley, F. Kong, S. Kruger, D. A. May, L. Curfman McInnes, R. Tran Mills, L. Mitchell, T. Munson, J. E. Roman, K. Rupp, P. Sanan, J. Sarich, B. F. Smith, H. Suh, S. Zampini, H. Zhang, H. Zhang, and J. Zhang. <em>PETSc/TAO Users Manual</em>. 2025. <a class="reference external" href="https://doi.org/10.2172/2998643">doi:10.2172/2998643</a>.</p>
</div>
<div class="citation" id="id9" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id3">Bal97</a><span class="fn-bracket">]</span></span>
<p>S. Balay, W. D. Gropp, L. C. McInnes, and B. F. Smith. Efficient management of parallelism in object oriented numerical software libraries. In E. Arge, A. M. Bruaset, and H. P. Langtangen, editors, <em>Modern Software Tools in Scientific Computing</em>, 163–202. Birkhaüser, 1997.</p>
</div>
<div class="citation" id="id65" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">Her09</a><span class="fn-bracket">]</span></span>
<p>V. Hernandez, J. E. Roman, A. Tomas, and V. Vidal. A survey of software for sparse eigenvalue problems. Technical Report STR-6, Universitat Politècnica de València, 2009. URL: <a class="reference external" href="https://slepc.upv.es/documentation">https://slepc.upv.es/documentation</a>.</p>
</div>
<div class="citation" id="id60" role="doc-biblioentry">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id5">MPI94</a><span class="fn-bracket">]</span></span>
<p>MPI Forum. MPI: a message-passing interface standard. <em>Int. J. Supercomp. Applic. High Perf. Comp.</em>, 8(3/4):159–416, 1994.</p>
</div>
</div>
</div>
</section>
</section>
</section>


                </article>
              
              
              
              
              
                <footer class="prev-next-footer d-print-none">
                  
<div class="prev-next-area">
    <a class="left-prev"
       href="index.html"
       title="previous page">
      <i class="fa-solid fa-angle-left"></i>
      <div class="prev-next-info">
        <p class="prev-next-subtitle">previous</p>
        <p class="prev-next-title">SLEPc Users Manual</p>
      </div>
    </a>
    <a class="right-next"
       href="eps.html"
       title="next page">
      <div class="prev-next-info">
        <p class="prev-next-subtitle">next</p>
        <p class="prev-next-title">EPS: Eigenvalue Problem Solver</p>
      </div>
      <i class="fa-solid fa-angle-right"></i>
    </a>
</div>
                </footer>
              
            </div>
            
            
              
                <dialog id="pst-secondary-sidebar-modal"></dialog>
                <div id="pst-secondary-sidebar" class="bd-sidebar-secondary bd-toc"><div class="sidebar-secondary-items sidebar-secondary__inner">


  <div class="sidebar-secondary-item">
<div
    id="pst-page-navigation-heading-2"
    class="page-toc tocsection onthispage">
    <i class="fa-solid fa-list"></i> On this page
  </div>
  <nav class="bd-toc-nav page-toc" aria-labelledby="pst-page-navigation-heading-2">
    <ul class="visible nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#slepc-and-petsc">SLEPc and PETSc</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-inst">Installation</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-std-inst">Standard Installation</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-opt-inst">Configuration Options</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-mult-inst">Installing Multiple Configurations in a Single Directory Tree</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-prefix-inst">Prefix-based Installation</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#running-slepc-programs">Running SLEPc Programs</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-writing-prog">Writing SLEPc Programs</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#sec-simpleex">Simple SLEPc Example</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#writing-application-codes-with-slepc">Writing Application Codes with SLEPc</a></li>
</ul>
</li>
</ul>
  </nav></div>

  <div class="sidebar-secondary-item">

  
  <div class="tocsection editthispage">
    <a href="https://gitlab.com/slepc/slepc/-/edit/release/doc/source/documentation/manual/intro.md">
      <i class="fa-solid fa-pencil"></i>
      
      
        
          Edit on GitLab
        
      
    </a>
  </div>
</div>

  <div class="sidebar-secondary-item">
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/documentation/manual/intro.md.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div></div>

</div></div>
              
            
          </div>
          <footer class="bd-footer-content">
            
          </footer>
        
      </main>
    </div>
  </div>
  
  <!-- Scripts loaded after <body> so the DOM is not blocked -->
  <script defer src="../../_static/scripts/bootstrap.js?digest=8878045cc6db502f8baf"></script>
<script defer src="../../_static/scripts/pydata-sphinx-theme.js?digest=8878045cc6db502f8baf"></script>

  <footer class="bd-footer">
<div class="bd-footer__inner bd-page-width">
  
    <div class="footer-items__start">
      
        <div class="footer-item">

  <p class="copyright">
    
      © Copyright 2002-2025, Universitat Politecnica de Valencia, Spain.
      <br/>
    
  </p>
</div>
      
        <div class="footer-item">

  <p class="sphinx-version">
    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.3.7.
    <br/>
  </p>
</div>
      
    </div>
  
  
  
    <div class="footer-items__end">
      
        <div class="footer-item">
<p class="theme-version">
  <!-- # L10n: Setting the PST URL as an argument as this does not need to be localized -->
  Built with the <a href="https://pydata-sphinx-theme.readthedocs.io/en/stable/index.html">PyData Sphinx Theme</a> 0.16.1.
</p></div>
      
    </div>
  
</div>

  </footer>
  </body>
</html>